working mbed program for Adafruit ST7735
Dependencies: Adafruit_GFX Adafruit_ST7735 SDFileSystem mbed-os
Fork of mbed-OLED-example-NCS36510 by
main.cpp@2:fa3fb1787cf8, 2017-01-31 (annotated)
- Committer:
- jacobjohnson
- Date:
- Tue Jan 31 17:16:30 2017 +0000
- Revision:
- 2:fa3fb1787cf8
- Parent:
- 0:8fbbced097c5
working code. need to get it into codeblocks to be able to trace function calls and learn how the libraries work, since they are not very well documented.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jacobjohnson | 2:fa3fb1787cf8 | 1 | /*************************************** |
jacobjohnson | 2:fa3fb1787cf8 | 2 | This is a working copy. It is not finished. |
jacobjohnson | 2:fa3fb1787cf8 | 3 | ***************************************/ |
jacobjohnson | 2:fa3fb1787cf8 | 4 | |
jacobjohnson | 0:8fbbced097c5 | 5 | #include "mbed.h" |
jacobjohnson | 2:fa3fb1787cf8 | 6 | #include "Adafruit_ST7735.h" |
jacobjohnson | 2:fa3fb1787cf8 | 7 | #include "SDFileSystem.h" |
jacobjohnson | 2:fa3fb1787cf8 | 8 | //#include <string> |
jacobjohnson | 0:8fbbced097c5 | 9 | |
jacobjohnson | 0:8fbbced097c5 | 10 | DigitalOut led1(LED1); |
jacobjohnson | 2:fa3fb1787cf8 | 11 | SDFileSystem sd(D11, D12, D13, D4, "SD"); // the pinout on the mbed // mosi, miso, sclk, cs |
jacobjohnson | 2:fa3fb1787cf8 | 12 | Adafruit_ST7735 tft(D11, D12, D13, D10, D6, D9); // MOSI, MISO, SCLK, SSEL, TFT_DC, TFT_RST |
jacobjohnson | 2:fa3fb1787cf8 | 13 | AnalogIn joystick(A3); |
jacobjohnson | 0:8fbbced097c5 | 14 | |
jacobjohnson | 2:fa3fb1787cf8 | 15 | uint8_t readButton(void); |
jacobjohnson | 2:fa3fb1787cf8 | 16 | |
jacobjohnson | 2:fa3fb1787cf8 | 17 | // main() runs in its own thread in the OS |
jacobjohnson | 2:fa3fb1787cf8 | 18 | // (note the calls to wait below for delays) |
jacobjohnson | 0:8fbbced097c5 | 19 | int main() { |
jacobjohnson | 2:fa3fb1787cf8 | 20 | |
jacobjohnson | 2:fa3fb1787cf8 | 21 | tft.initR(INITR_BLACKTAB); // initialize a ST7735S chip, black tab |
jacobjohnson | 2:fa3fb1787cf8 | 22 | tft.fillScreen(ST7735_BLACK); |
jacobjohnson | 0:8fbbced097c5 | 23 | |
jacobjohnson | 2:fa3fb1787cf8 | 24 | int result = tft.DrawBitmapFile("/SD/ON.bmp"); |
jacobjohnson | 2:fa3fb1787cf8 | 25 | |
jacobjohnson | 2:fa3fb1787cf8 | 26 | while (true) { |
jacobjohnson | 2:fa3fb1787cf8 | 27 | |
jacobjohnson | 2:fa3fb1787cf8 | 28 | float b = joystick.read(); |
jacobjohnson | 2:fa3fb1787cf8 | 29 | |
jacobjohnson | 2:fa3fb1787cf8 | 30 | tft.setTextColor(ST7735_GREEN); |
jacobjohnson | 2:fa3fb1787cf8 | 31 | //tft.setCursor(0, 60); //claims that this is not in the Adafruit_ST7735 library? How are these files linked together? |
jacobjohnson | 2:fa3fb1787cf8 | 32 | tft.printf("%f \n\r", b); |
jacobjohnson | 2:fa3fb1787cf8 | 33 | printf("%f \n\r", b); |
jacobjohnson | 2:fa3fb1787cf8 | 34 | wait_ms(100); |
jacobjohnson | 2:fa3fb1787cf8 | 35 | |
jacobjohnson | 2:fa3fb1787cf8 | 36 | |
jacobjohnson | 0:8fbbced097c5 | 37 | } |
jacobjohnson | 0:8fbbced097c5 | 38 | } |
jacobjohnson | 0:8fbbced097c5 | 39 | |
jacobjohnson | 2:fa3fb1787cf8 | 40 | |
jacobjohnson | 2:fa3fb1787cf8 | 41 |