Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By Iskariot
#37635 Great work sumotoy!!

Your library worked "out of the box"

I have however, been having some problems with the bitmap drawing example.
The program suggested for converting bitmaps to c code produces less than height*width number of elements in the array.
I may be doing something wrong however.
I wrote my own program in processing to do the conversion, and that worked. The only problem is that if i try to draw the bitmap at any other location on the screen other than x=0,y=0 the bitmap turns to partial garbage, or is not drawn at all, depending on the position.

I suspect that the error is in the constraint window method setAddrWindow_cont(x,y,w,h);
I used the drawPixel method as a workaround for now. It works fine and it is still pretty fast, but it is probably a slower way to draw the bitmap than the "correct" way.

Here is the workaround if anyone wants it:
Code: Select allvoid drawcbmp(int16_t x, int16_t y, int16_t w, int16_t h, const uint32_t *bitmap,bool true24)
{
  int16_t px;
  uint16_t color;
  int16_t cx = 0;
  int16_t cy = 0;
 
  for (px = 0;px < w*h; px++){//loop trough pixels
    if (true24){
      color = tft.Color24To565(pgm_read_dword(bitmap + px));//bitmap[px]);//24 bit
    } else {
      color = pgm_read_word(bitmap + px);//bitmap[px];//18 bit
    }
   
      tft.drawPixel(x+cx,y+cy,color);
      cx++;
      if(cx>=w)
      {
        cx = 0;
        cy++;
      }
      yield();
  }
}


Here is what I'm using it for:
Image
User avatar
By sumotoy
#37698 Can you post the image (already converted, the array)? I want investigate this.
Using draw pixel works but it's clearly slow, every pixels has to be addressed, better use pixel stream, much faster!
I have an idea of the bug and in all cases I'm working on icons from november, I will use it on all TFT/OLED libraries.
User avatar
By Iskariot
#37715 It may still be the case that i'm doing the image conversion wrong because to make the image work in the loadimage_noSD example i have to set the image size to width-1 or it will be drawn scewed (kind of hard to explain, but for each pixel line in the height direction, the image is shifted one pixel to the left)

I have attached a modified version of the example program with the image. Here you should be able to see the width problem explained above, and test drawing the image at different positions:
Code: Select all#include <SPI.h>
#include <TFT_ILI9163C.h>
/*
ESP8266-----------------------------------
Use:*/
#define __CS  16  //(D0)
#define __DC  5   //(D1)
#define __RST 4   //(D2)

TFT_ILI9163C tft = TFT_ILI9163C(__CS, __DC,__RST);

static const uint32_t sun[1024] PROGMEM = {
0xffffff,
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfef9f2, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfeefde, 0xfbc477, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfcce86, 0xfcb72b, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfcb82f, 0xfec01b, 0xfdece0, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfcd6a4, 0xfef1e8, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfde9d9, 0xfebf1f, 0xfec829, 0xfccd84, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfbca89, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfef1e8, 0xfba80, 0xfcc15d, 0xfdeee3, 0xffffff, 0xffffff, 0xffffff, 0xfbc979, 0xfabd25, 0xfabd2d, 0xfaaf2a, 0xffffff, 0xffffff, 0xffffff, 0xfefdff, 0xfccd88, 0xfcb3d, 0xfccd88, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfcc15d, 0xffcc27, 0xfebd1a, 0xfbbc51, 0xfeead6, 0xffffff, 0xf8aa24, 0xf7b328, 0xf7b22b, 0xf6aa17, 0xfeecdb, 0xfffdfe, 0xfbc679, 0xfaae19, 0xffc927, 0xfcb51b, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfdeee3, 0xfebc1a, 0xfdc933, 0xfbbf2a, 0xf8ac16, 0xf8a934, 0xf7b028, 0xf8bb34, 0xf9b82b, 0xf5af27, 0xf7a836, 0xf5a41a, 0xf7b121, 0xf9b92e, 0xfbbe24, 0xfccd89, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfcbe52, 0xfbc02b, 0xf8b62a, 0xf7b32d, 0xfdd367, 0xffdf7d, 0xffd968, 0xffd146, 0xfdc731, 0xf8b82b, 0xf4aa27, 0xf5ac29, 0xf6b22a, 0xf8a817, 0xfefeff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfeead6, 0xf8ae16, 0xf7b42c, 0xffde82, 0xffe7a4, 0xffe5a2, 0xffde85, 0xffd55e, 0xffcb36, 0xfabe2f, 0xf5b02b, 0xf2a627, 0xf4a91e, 0xfbc77c, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xf8aa37, 0xfdcf57, 0xffe392, 0xffebba, 0xffebbc, 0xffe192, 0xffd767, 0xffcc3a, 0xfbbf2e, 0xf6b22c, 0xf1a326, 0xf39b12, 0xfff7f3, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfde9d8, 0xfcc97a, 0xfaae25, 0xf8b326, 0xffd75e, 0xffde84, 0xffe5a3, 0xffe5a3, 0xffde85, 0xffd55f, 0xfeca36, 0xfabe2f, 0xf6b02b, 0xf0a325, 0xf09e22, 0xf5a31b, 0xfabb58, 0xfddebb, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
0xffffff, 0xffffff, 0xffffff, 0xfeefde, 0xfcce85, 0xfcb82f, 0xfec11f, 0xfdc529, 0xf9b92c, 0xf9ba2c, 0xffd145, 0xffd766, 0xffdb79, 0xffdb7a, 0xffd768, 0xffd046, 0xfdc630, 0xf9ba2e, 0xf4ad29, 0xf0a024, 0xed9721, 0xf5ab28, 0xf6b124, 0xf9b61c, 0xfcb31f, 0xfcc76a, 0xfde2c0, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
0xffffff, 0xffffff, 0xfef8f2, 0xfcc578, 0xfcb72b, 0xfec01b, 0xffcb2a, 0xfdc630, 0xf9ba2e, 0xf8b72e, 0xfdc731, 0xffce3d, 0xffd14c, 0xffd14d, 0xffce3e, 0xfec731, 0xfbbe2f, 0xf6b32b, 0xf3a728, 0xee9b22, 0xec9520, 0xf5ab29, 0xf6b32a, 0xf9ba26, 0xfec220, 0xfcb61a, 0xfcbf5e, 0xfde7cd, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfdece0, 0xfccd84, 0xfcb42c, 0xf9b21a, 0xf7b328, 0xf9bc2e, 0xfcc230, 0xfdc530, 0xfdc530, 0xfcc230, 0xfabc2f, 0xf7b42c, 0xf4ab28, 0xf0a124, 0xec9420, 0xed9721, 0xf4a618, 0xf8a71a, 0xfbc164, 0xfde1c3, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfeecdb, 0xf8ad38, 0xf5af28, 0xf7b52d, 0xf9b82d, 0xf8b82d, 0xf7b52c, 0xf6b12b, 0xf3aa28, 0xf0a225, 0xed9821, 0xe98e1d, 0xf29a16, 0xfeddb7, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfffcfe, 0xf8ac1e, 0xf5af29, 0xf2a627, 0xf4ab28, 0xf4ab29, 0xf3a928, 0xf2a526, 0xf09f24, 0xed9721, 0xe98e1d, 0xed9821, 0xf4a71a, 0xfddbaf, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfcc97a, 0xfbbc25, 0xf8b72d, 0xf4aa28, 0xee9c22, 0xee9b23, 0xee9a23, 0xec9721, 0xeb911f, 0xe98d1d, 0xed9922, 0xf5ac29, 0xf6af28, 0xf8ab2a, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfefcff, 0xfdb61c, 0xfdc632, 0xfabd2e, 0xf8b523, 0xf6a215, 0xf0a023, 0xed9721, 0xec9620, 0xee9b22, 0xf39c17, 0xf5a91b, 0xf7b228, 0xf8b72d, 0xfab61c, 0xfddcb4, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfccc88, 0xffcb28, 0xffca28, 0xfbb11a, 0xfbc87d, 0xfff6f3, 0xf8aa1e, 0xf7b42b, 0xf7b32b, 0xf6ad1b, 0xfeddb7, 0xfddbaf, 0xf9ac2a, 0xfab81d, 0xfec82c, 0xfcb633, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfcb3d, 0xfdb51b, 0xfccd89, 0xfefdff, 0xffffff, 0xffffff, 0xfbbe5a, 0xf9ba27, 0xf9b92d, 0xf9ab1c, 0xffffff, 0xffffff, 0xffffff, 0xfddcb3, 0xfcb733, 0xfebda, 0xfddfbd, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfbc989, 0xfccd88, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfddebb, 0xfdc121, 0xfdc42a, 0xfcc365, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfcdfbd, 0xfab24a, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfcb620, 0xffc621, 0xfde1c3, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfffefd, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfcc66a, 0xfdb51b, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfde2c0, 0xfbbf5e, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfde7cd, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff
};

void setup() {
  tft.begin();
  tft.setRotation(2);
  tft.setBackground(BLACK);
  tft.clearScreen();
 
  tft.drawColorBitmap(0,0,31,32,sun);// <- works. Note the width parameter not being correct. Try setting it to 32,32.
  //tft.drawColorBitmap(7,7,31,32,sun);// <- does not work
}

void loop(void) {

}