![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
For Pet_Finder
Dependencies: Adafruit_GFX Adafruit_ST7735 Adafruit_TFT_Shieldv1_graphicstest SDFileSystem mbed
Fork of Adafruit_TFT_Shieldv1_graphicstest by
main.cpp@2:e64c231f0abb, 2017-05-16 (annotated)
- Committer:
- GabrielGoichman
- Date:
- Tue May 16 13:41:02 2017 +0000
- Revision:
- 2:e64c231f0abb
- Parent:
- 0:b0981712db9b
- Child:
- 4:41b8a8713b49
First Version for IHM_GX to Pet-Finder
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
justinkim | 0:b0981712db9b | 1 | #include "mbed.h" |
justinkim | 0:b0981712db9b | 2 | #include "Adafruit_ST7735.h" |
justinkim | 0:b0981712db9b | 3 | |
GabrielGoichman | 2:e64c231f0abb | 4 | |
justinkim | 0:b0981712db9b | 5 | Adafruit_ST7735 tft(D11, D12, D13, D10, D8, D9); // MOSI, MISO, SCLK, SSEL, TFT_DC, TFT_RST |
justinkim | 0:b0981712db9b | 6 | |
justinkim | 0:b0981712db9b | 7 | void testlines(uint16_t color); |
justinkim | 0:b0981712db9b | 8 | void testfastlines(uint16_t color1, uint16_t color2); |
GabrielGoichman | 2:e64c231f0abb | 9 | void IniciandoMaquina(void); |
GabrielGoichman | 2:e64c231f0abb | 10 | void Alerta(void); |
GabrielGoichman | 2:e64c231f0abb | 11 | void MenuPrincipal(void); |
GabrielGoichman | 2:e64c231f0abb | 12 | void Aguarde(void); |
GabrielGoichman | 2:e64c231f0abb | 13 | void Executando(void); |
justinkim | 0:b0981712db9b | 14 | |
justinkim | 0:b0981712db9b | 15 | int main(void) |
justinkim | 0:b0981712db9b | 16 | { |
GabrielGoichman | 2:e64c231f0abb | 17 | // Use this initializer if you're using a 1.8" TFT |
GabrielGoichman | 2:e64c231f0abb | 18 | tft.initR(INITR_BLACKTAB); // initialize a ST7735S chip, black tab |
justinkim | 0:b0981712db9b | 19 | |
GabrielGoichman | 2:e64c231f0abb | 20 | //iniciando máquina |
GabrielGoichman | 2:e64c231f0abb | 21 | IniciandoMaquina(); |
GabrielGoichman | 2:e64c231f0abb | 22 | wait_ms(5000); |
GabrielGoichman | 2:e64c231f0abb | 23 | Alerta(); |
GabrielGoichman | 2:e64c231f0abb | 24 | wait_ms(5000); |
GabrielGoichman | 2:e64c231f0abb | 25 | MenuPrincipal(); |
GabrielGoichman | 2:e64c231f0abb | 26 | wait_ms(5000); |
GabrielGoichman | 2:e64c231f0abb | 27 | Aguarde(); |
GabrielGoichman | 2:e64c231f0abb | 28 | wait_ms(5000); |
GabrielGoichman | 2:e64c231f0abb | 29 | Executando(); |
GabrielGoichman | 2:e64c231f0abb | 30 | wait_ms(5000); |
GabrielGoichman | 2:e64c231f0abb | 31 | //InicioProcessoReferenciamento(); |
GabrielGoichman | 2:e64c231f0abb | 32 | //wait_ms(5000); |
justinkim | 0:b0981712db9b | 33 | } |
justinkim | 0:b0981712db9b | 34 | |
GabrielGoichman | 2:e64c231f0abb | 35 | // ---------------------------------------------------------------------------------------------------------------- |
GabrielGoichman | 2:e64c231f0abb | 36 | |
GabrielGoichman | 2:e64c231f0abb | 37 | |
GabrielGoichman | 2:e64c231f0abb | 38 | void testlines(uint16_t color) |
GabrielGoichman | 2:e64c231f0abb | 39 | { |
GabrielGoichman | 2:e64c231f0abb | 40 | tft.fillScreen(ST7735_BLACK); |
GabrielGoichman | 2:e64c231f0abb | 41 | for (int16_t x=0; x < tft.width(); x+=6) { |
GabrielGoichman | 2:e64c231f0abb | 42 | tft.drawLine(0, 0, x, tft.height()-1, color); |
GabrielGoichman | 2:e64c231f0abb | 43 | } |
GabrielGoichman | 2:e64c231f0abb | 44 | for (int16_t y=0; y < tft.height(); y+=6) { |
GabrielGoichman | 2:e64c231f0abb | 45 | tft.drawLine(0, 0, tft.width()-1, y, color); |
GabrielGoichman | 2:e64c231f0abb | 46 | } |
justinkim | 0:b0981712db9b | 47 | |
GabrielGoichman | 2:e64c231f0abb | 48 | tft.fillScreen(ST7735_BLACK); |
GabrielGoichman | 2:e64c231f0abb | 49 | for (int16_t x=0; x < tft.width(); x+=6) { |
GabrielGoichman | 2:e64c231f0abb | 50 | tft.drawLine(tft.width()-1, 0, x, tft.height()-1, color); |
GabrielGoichman | 2:e64c231f0abb | 51 | } |
GabrielGoichman | 2:e64c231f0abb | 52 | for (int16_t y=0; y < tft.height(); y+=6) { |
GabrielGoichman | 2:e64c231f0abb | 53 | tft.drawLine(tft.width()-1, 0, 0, y, color); |
GabrielGoichman | 2:e64c231f0abb | 54 | } |
justinkim | 0:b0981712db9b | 55 | |
GabrielGoichman | 2:e64c231f0abb | 56 | tft.fillScreen(ST7735_BLACK); |
GabrielGoichman | 2:e64c231f0abb | 57 | for (int16_t x=0; x < tft.width(); x+=6) { |
GabrielGoichman | 2:e64c231f0abb | 58 | tft.drawLine(0, tft.height()-1, x, 0, color); |
GabrielGoichman | 2:e64c231f0abb | 59 | } |
GabrielGoichman | 2:e64c231f0abb | 60 | for (int16_t y=0; y < tft.height(); y+=6) { |
GabrielGoichman | 2:e64c231f0abb | 61 | tft.drawLine(0, tft.height()-1, tft.width()-1, y, color); |
GabrielGoichman | 2:e64c231f0abb | 62 | } |
justinkim | 0:b0981712db9b | 63 | |
GabrielGoichman | 2:e64c231f0abb | 64 | tft.fillScreen(ST7735_BLACK); |
GabrielGoichman | 2:e64c231f0abb | 65 | for (int16_t x=0; x < tft.width(); x+=6) { |
GabrielGoichman | 2:e64c231f0abb | 66 | tft.drawLine(tft.width()-1, tft.height()-1, x, 0, color); |
GabrielGoichman | 2:e64c231f0abb | 67 | } |
GabrielGoichman | 2:e64c231f0abb | 68 | for (int16_t y=0; y < tft.height(); y+=6) { |
GabrielGoichman | 2:e64c231f0abb | 69 | tft.drawLine(tft.width()-1, tft.height()-1, 0, y, color); |
GabrielGoichman | 2:e64c231f0abb | 70 | } |
justinkim | 0:b0981712db9b | 71 | } |
justinkim | 0:b0981712db9b | 72 | |
GabrielGoichman | 2:e64c231f0abb | 73 | void testfastlines(uint16_t color1, uint16_t color2) |
GabrielGoichman | 2:e64c231f0abb | 74 | { |
GabrielGoichman | 2:e64c231f0abb | 75 | tft.fillScreen(ST7735_BLACK); |
GabrielGoichman | 2:e64c231f0abb | 76 | for (int16_t y=0; y < tft.height(); y+=5) { |
GabrielGoichman | 2:e64c231f0abb | 77 | tft.drawFastHLine(0, y, tft.width(), color1); |
GabrielGoichman | 2:e64c231f0abb | 78 | } |
GabrielGoichman | 2:e64c231f0abb | 79 | for (int16_t x=0; x < tft.width(); x+=5) { |
GabrielGoichman | 2:e64c231f0abb | 80 | tft.drawFastVLine(x, 0, tft.height(), color2); |
GabrielGoichman | 2:e64c231f0abb | 81 | } |
justinkim | 0:b0981712db9b | 82 | } |
justinkim | 0:b0981712db9b | 83 | |
GabrielGoichman | 2:e64c231f0abb | 84 | |
justinkim | 0:b0981712db9b | 85 | |
GabrielGoichman | 2:e64c231f0abb | 86 | void IniciandoMaquina() |
GabrielGoichman | 2:e64c231f0abb | 87 | { |
GabrielGoichman | 2:e64c231f0abb | 88 | tft.setTextWrap(true); |
GabrielGoichman | 2:e64c231f0abb | 89 | tft.fillScreen(ST7735_BLACK); |
GabrielGoichman | 2:e64c231f0abb | 90 | int x = 0; |
GabrielGoichman | 2:e64c231f0abb | 91 | while(x < 5) { |
GabrielGoichman | 2:e64c231f0abb | 92 | tft.fillScreen(ST7735_BLACK); |
GabrielGoichman | 2:e64c231f0abb | 93 | tft.setCursor(0,50); |
GabrielGoichman | 2:e64c231f0abb | 94 | tft.setTextColor(ST7735_WHITE); |
GabrielGoichman | 2:e64c231f0abb | 95 | tft.setTextSize(2); |
GabrielGoichman | 2:e64c231f0abb | 96 | tft.printf("Iniciando Pet-Finder"); |
GabrielGoichman | 2:e64c231f0abb | 97 | tft.setCursor(0,100); |
GabrielGoichman | 2:e64c231f0abb | 98 | tft.printf("Aguarde"); |
GabrielGoichman | 2:e64c231f0abb | 99 | wait_ms(100); |
GabrielGoichman | 2:e64c231f0abb | 100 | tft.fillScreen(ST7735_BLACK); |
GabrielGoichman | 2:e64c231f0abb | 101 | tft.setCursor(0,50); |
GabrielGoichman | 2:e64c231f0abb | 102 | tft.setTextColor(ST7735_WHITE); |
GabrielGoichman | 2:e64c231f0abb | 103 | tft.setTextSize(2); |
GabrielGoichman | 2:e64c231f0abb | 104 | tft.printf("Iniciando Pet-Finder"); |
GabrielGoichman | 2:e64c231f0abb | 105 | tft.setCursor(0,100); |
GabrielGoichman | 2:e64c231f0abb | 106 | tft.printf("Aguarde..."); |
GabrielGoichman | 2:e64c231f0abb | 107 | wait_ms(100); |
GabrielGoichman | 2:e64c231f0abb | 108 | x += 1; |
justinkim | 0:b0981712db9b | 109 | } |
justinkim | 0:b0981712db9b | 110 | } |
justinkim | 0:b0981712db9b | 111 | |
GabrielGoichman | 2:e64c231f0abb | 112 | |
justinkim | 0:b0981712db9b | 113 | |
GabrielGoichman | 2:e64c231f0abb | 114 | void Alerta() { |
GabrielGoichman | 2:e64c231f0abb | 115 | tft.setTextWrap(true); |
GabrielGoichman | 2:e64c231f0abb | 116 | int x = 0; |
GabrielGoichman | 2:e64c231f0abb | 117 | while(x < 10) { |
GabrielGoichman | 2:e64c231f0abb | 118 | tft.fillScreen(ST7735_BLACK); |
GabrielGoichman | 2:e64c231f0abb | 119 | tft.setCursor(0,50); |
GabrielGoichman | 2:e64c231f0abb | 120 | tft.setTextColor(ST7735_WHITE); |
GabrielGoichman | 2:e64c231f0abb | 121 | tft.setTextSize(2); |
GabrielGoichman | 2:e64c231f0abb | 122 | tft.printf("!!ALERTA!!"); |
GabrielGoichman | 2:e64c231f0abb | 123 | wait_ms(200); |
GabrielGoichman | 2:e64c231f0abb | 124 | tft.fillScreen(ST7735_RED); |
GabrielGoichman | 2:e64c231f0abb | 125 | tft.setTextSize(2); |
GabrielGoichman | 2:e64c231f0abb | 126 | tft.printf("!!ALERTA!!"); |
GabrielGoichman | 2:e64c231f0abb | 127 | wait_ms(300); |
GabrielGoichman | 2:e64c231f0abb | 128 | x += 1; |
GabrielGoichman | 2:e64c231f0abb | 129 | } |
GabrielGoichman | 2:e64c231f0abb | 130 | |
justinkim | 0:b0981712db9b | 131 | } |
justinkim | 0:b0981712db9b | 132 | |
GabrielGoichman | 2:e64c231f0abb | 133 | void MenuPrincipal() { |
GabrielGoichman | 2:e64c231f0abb | 134 | tft.fillScreen(ST7735_BLACK); |
GabrielGoichman | 2:e64c231f0abb | 135 | tft.setCursor(0,0); |
GabrielGoichman | 2:e64c231f0abb | 136 | tft.setTextColor(ST7735_WHITE); |
GabrielGoichman | 2:e64c231f0abb | 137 | tft.setTextSize(2); |
GabrielGoichman | 2:e64c231f0abb | 138 | tft.printf("Pet-Finder"); |
GabrielGoichman | 2:e64c231f0abb | 139 | tft.setCursor(0,40); |
GabrielGoichman | 2:e64c231f0abb | 140 | tft.printf("Data:"); |
GabrielGoichman | 2:e64c231f0abb | 141 | tft.setCursor(0,55); |
GabrielGoichman | 2:e64c231f0abb | 142 | tft.printf("15/05/2017"); |
GabrielGoichman | 2:e64c231f0abb | 143 | tft.setCursor(0,80); |
GabrielGoichman | 2:e64c231f0abb | 144 | tft.printf("Horario:"); |
GabrielGoichman | 2:e64c231f0abb | 145 | tft.setCursor(0,95); |
GabrielGoichman | 2:e64c231f0abb | 146 | tft.printf("17h27"); |
GabrielGoichman | 2:e64c231f0abb | 147 | wait_ms(200); |
GabrielGoichman | 2:e64c231f0abb | 148 | |
GabrielGoichman | 2:e64c231f0abb | 149 | } |
GabrielGoichman | 2:e64c231f0abb | 150 | |
GabrielGoichman | 2:e64c231f0abb | 151 | void Aguarde() { |
justinkim | 0:b0981712db9b | 152 | int x = 0; |
GabrielGoichman | 2:e64c231f0abb | 153 | while(x < 5) { |
GabrielGoichman | 2:e64c231f0abb | 154 | tft.fillScreen(ST7735_BLACK); |
GabrielGoichman | 2:e64c231f0abb | 155 | tft.setCursor(0,70); |
GabrielGoichman | 2:e64c231f0abb | 156 | tft.setTextSize(2); |
GabrielGoichman | 2:e64c231f0abb | 157 | tft.printf("Aguarde..."); |
GabrielGoichman | 2:e64c231f0abb | 158 | wait_ms(800); |
GabrielGoichman | 2:e64c231f0abb | 159 | x += 1; |
justinkim | 0:b0981712db9b | 160 | } |
GabrielGoichman | 2:e64c231f0abb | 161 | } |
GabrielGoichman | 2:e64c231f0abb | 162 | |
GabrielGoichman | 2:e64c231f0abb | 163 | void Executando() { |
GabrielGoichman | 2:e64c231f0abb | 164 | int x = 0; |
GabrielGoichman | 2:e64c231f0abb | 165 | tft.fillScreen(ST7735_WHITE); |
GabrielGoichman | 2:e64c231f0abb | 166 | tft.setTextColor(ST7735_BLACK); |
GabrielGoichman | 2:e64c231f0abb | 167 | while(x < 3) { |
GabrielGoichman | 2:e64c231f0abb | 168 | tft.fillScreen(ST7735_GREEN); |
GabrielGoichman | 2:e64c231f0abb | 169 | tft.setCursor(0,70); |
GabrielGoichman | 2:e64c231f0abb | 170 | tft.setTextSize(2); |
GabrielGoichman | 2:e64c231f0abb | 171 | tft.printf("Executando"); |
GabrielGoichman | 2:e64c231f0abb | 172 | wait_ms(800); |
GabrielGoichman | 2:e64c231f0abb | 173 | tft.fillScreen(ST7735_WHITE); |
GabrielGoichman | 2:e64c231f0abb | 174 | tft.setTextColor(ST7735_BLACK); |
GabrielGoichman | 2:e64c231f0abb | 175 | tft.setCursor(0,70); |
GabrielGoichman | 2:e64c231f0abb | 176 | tft.printf("Executando"); |
GabrielGoichman | 2:e64c231f0abb | 177 | wait_ms(400); |
GabrielGoichman | 2:e64c231f0abb | 178 | x += 1; |
GabrielGoichman | 2:e64c231f0abb | 179 | |
GabrielGoichman | 2:e64c231f0abb | 180 | } |
GabrielGoichman | 2:e64c231f0abb | 181 | tft.fillScreen(ST7735_GREEN); |
GabrielGoichman | 2:e64c231f0abb | 182 | tft.setCursor(0,70); |
GabrielGoichman | 2:e64c231f0abb | 183 | tft.printf("Executando"); |
justinkim | 0:b0981712db9b | 184 | } |
justinkim | 0:b0981712db9b | 185 | |
justinkim | 0:b0981712db9b | 186 | |
GabrielGoichman | 2:e64c231f0abb | 187 | // ---------------------------------------------------------------------------------------------------------------- |
justinkim | 0:b0981712db9b | 188 | |
GabrielGoichman | 2:e64c231f0abb | 189 |