|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222 |
- /*
- An example of how easy it's upload custom 8x16 symbols.
- RA8875 has 255 locations reserved for user custom designed symbols.
- */
-
- #include <SPI.h>
- #include <RA8875.h>
-
-
- #define RA8875_CS 10
-
- #define RA8875_RESET 9//any pin or nothing!
-
-
- RA8875 tft = RA8875(RA8875_CS, RA8875_RESET);
-
-
- //define some custom char (8x16)
- const uint8_t battery1[16] = {
- 0b00111000,
- 0b00111000,
- 0b11111111,
- 0b10000001,
- 0b10111101,
- 0b10111101,
- 0b10111101,
- 0b10111101,
- 0b10111101,
- 0b10111101,
- 0b10111101,
- 0b10111101,
- 0b10111101,
- 0b10111101,
- 0b10000001,
- 0b11111111
- };
-
- const uint8_t battery2[16] = {
- 0b00111000,
- 0b00111000,
- 0b11111111,
- 0b10000001,
- 0b10000001,
- 0b10000001,
- 0b10111101,
- 0b10111101,
- 0b10111101,
- 0b10111101,
- 0b10111101,
- 0b10111101,
- 0b10111101,
- 0b10111101,
- 0b10000001,
- 0b11111111
- };
-
- const uint8_t battery3[16] = {
- 0b00111000,
- 0b00111000,
- 0b11111111,
- 0b10000001,
- 0b10000001,
- 0b10000001,
- 0b10000001,
- 0b10000001,
- 0b10111101,
- 0b10111101,
- 0b10111101,
- 0b10111101,
- 0b10111101,
- 0b10111101,
- 0b10000001,
- 0b11111111
- };
-
- const uint8_t battery4[16] = {
- 0b00111000,
- 0b00111000,
- 0b11111111,
- 0b10000001,
- 0b10000001,
- 0b10000001,
- 0b10000001,
- 0b10000001,
- 0b10000001,
- 0b10000001,
- 0b10111101,
- 0b10111101,
- 0b10111101,
- 0b10111101,
- 0b10000001,
- 0b11111111
- };
-
- const uint8_t battery5[16] = {
- 0b00111000,
- 0b00111000,
- 0b11111111,
- 0b10000001,
- 0b10000001,
- 0b10000001,
- 0b10000001,
- 0b10000001,
- 0b10000001,
- 0b10000001,
- 0b10000001,
- 0b10000001,
- 0b10000001,
- 0b10000001,
- 0b10000001,
- 0b11111111
- };
-
- //next 3 are part of the same char
- const uint8_t battery6a[16] = {
- 0b00000111,
- 0b00000111,
- 0b11111111,
- 0b11000000,
- 0b11000000,
- 0b11000000,
- 0b11110000,
- 0b11111100,
- 0b11111111,
- 0b11111111,
- 0b11111111,
- 0b11111111,
- 0b11111111,
- 0b11111111,
- 0b00000000,
- 0b00000000
- };
-
- const uint8_t battery6b[16] = {
- 0b11100000,
- 0b11100000,
- 0b11111111,
- 0b00000011,
- 0b00000011,
- 0b00000011,
- 0b00000011,
- 0b00000011,
- 0b00000011,
- 0b11000011,
- 0b11110011,
- 0b11111111,
- 0b11111111,
- 0b11111111,
- 0b00000000,
- 0b00000000
- };
-
- const uint8_t battery6c[16] = {
- 0b00011111,
- 0b00000011,
- 0b00001111,
- 0b00000011,
- 0b00011111,
- 0b00000000,
- 0b00011111,
- 0b00000011,
- 0b00001111,
- 0b00000011,
- 0b00011111,
- 0b00000000,
- 0b00000000,
- 0b00000000,
- 0b00000000,
- 0b00000000
- };
-
- void setup()
- {
-
- uint8_t i;
- tft.begin(RA8875_800x480);
- //upload chars in address 0x00 to 0x04
- tft.uploadUserChar(battery1, 0); //0x00
- tft.uploadUserChar(battery2, 1);
- tft.uploadUserChar(battery3, 2);
- tft.uploadUserChar(battery4, 3);
- tft.uploadUserChar(battery5, 4); //0x04
- tft.uploadUserChar(battery6a, 5); //
- tft.uploadUserChar(battery6b, 6); //
- tft.uploadUserChar(battery6c, 7); //
- //now custom char are stored in CGRAM
- tft.setTextColor(RA8875_WHITE, RA8875_BLACK);
- tft.setFontScale(0);
- for (i = 0; i < 5; i++) {
- tft.setCursor(tft.width() / 2, tft.height() / 2);
- tft.showUserChar(i);//retrieve from 0x00 to 0x04
- delay(200);
- }
- tft.setFontScale(0);
- }
-
- uint8_t rot;
- void loop()
- {
- uint8_t i;
- tft.clearScreen();//exact as tft.fillScreen();
- tft.setRotation(rot);
- tft.setTextColor(RA8875_WHITE, RA8875_BLACK);
- //custom char are managed as text but need to be called
- //by a special function
- //the only text parameter that is not accepted is setFontScale!
- for (i = 0; i < 5; i++) {
- tft.setCursor(10, 10);
- tft.showUserChar(i);//retrieve from 0x00 to 0x04
- delay(200);
- }
-
- //now another feature, you can design a char wider
- //by using many char slot combined.
- //below an example, 3 chars wider
- tft.setTextColor(RA8875_LIGHT_ORANGE);
- tft.setCursor(30, 11);
- tft.showUserChar(5, 2);
- delay(1000);
- if (rot > 3) rot = 0;
- rot++;
- }
|