K64F Powered ssd1306 128*64 spi OLED
Dependencies: Adafruit_GFX mbed
mbed-src/main.cpp@0:11f19153c7da, 2016-08-10 (annotated)
- Committer:
- sampleCode
- Date:
- Wed Aug 10 05:18:17 2016 +0000
- Revision:
- 0:11f19153c7da
- Child:
- 1:63facd5c734a
k64f powered ssd1306 128*64 spi oled display
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sampleCode | 0:11f19153c7da | 1 | /* |
sampleCode | 0:11f19153c7da | 2 | k64F -- OLED |
sampleCode | 0:11f19153c7da | 3 | D11 mosi/D0 |
sampleCode | 0:11f19153c7da | 4 | D13 sck/D1 |
sampleCode | 0:11f19153c7da | 5 | D5 CS |
sampleCode | 0:11f19153c7da | 6 | D6 DC |
sampleCode | 0:11f19153c7da | 7 | D7 RST |
sampleCode | 0:11f19153c7da | 8 | */ |
sampleCode | 0:11f19153c7da | 9 | #include "mbed.h" |
sampleCode | 0:11f19153c7da | 10 | #include "Adafruit_SSD1306.h" |
sampleCode | 0:11f19153c7da | 11 | |
sampleCode | 0:11f19153c7da | 12 | DigitalOut myled(LED2); |
sampleCode | 0:11f19153c7da | 13 | |
sampleCode | 0:11f19153c7da | 14 | // an SPI sub-class that provides a constructed default |
sampleCode | 0:11f19153c7da | 15 | class SPIPreInit : public SPI |
sampleCode | 0:11f19153c7da | 16 | { |
sampleCode | 0:11f19153c7da | 17 | public: |
sampleCode | 0:11f19153c7da | 18 | SPIPreInit(PinName mosi, PinName miso, PinName clk) : SPI(mosi,miso,clk) |
sampleCode | 0:11f19153c7da | 19 | { |
sampleCode | 0:11f19153c7da | 20 | format(8,3); |
sampleCode | 0:11f19153c7da | 21 | frequency(2000000); |
sampleCode | 0:11f19153c7da | 22 | }; |
sampleCode | 0:11f19153c7da | 23 | }; |
sampleCode | 0:11f19153c7da | 24 | |
sampleCode | 0:11f19153c7da | 25 | SPIPreInit mySpi(D11,NC,D13); |
sampleCode | 0:11f19153c7da | 26 | Adafruit_SSD1306_Spi myOled(mySpi,D6,D7,D5,64,128); |
sampleCode | 0:11f19153c7da | 27 | |
sampleCode | 0:11f19153c7da | 28 | int main() |
sampleCode | 0:11f19153c7da | 29 | { |
sampleCode | 0:11f19153c7da | 30 | uint16_t x=0; |
sampleCode | 0:11f19153c7da | 31 | myOled.clearDisplay(); |
sampleCode | 0:11f19153c7da | 32 | myOled.printf("%ux%u OLED Display\r\n", myOled.width(), myOled.height()); |
sampleCode | 0:11f19153c7da | 33 | myOled.setTextCursor(0,17); |
sampleCode | 0:11f19153c7da | 34 | myOled.printf("blog:engoythe.party\r\n"); |
sampleCode | 0:11f19153c7da | 35 | myOled.printf("qq:1028917076\r\n"); |
sampleCode | 0:11f19153c7da | 36 | myOled.printf("phone:1709005xxxxx\r\n"); |
sampleCode | 0:11f19153c7da | 37 | while(1) |
sampleCode | 0:11f19153c7da | 38 | { |
sampleCode | 0:11f19153c7da | 39 | myled = !myled; |
sampleCode | 0:11f19153c7da | 40 | myOled.printf("%u\r ",x); |
sampleCode | 0:11f19153c7da | 41 | myOled.display(); |
sampleCode | 0:11f19153c7da | 42 | x++; |
sampleCode | 0:11f19153c7da | 43 | wait(1.0); |
sampleCode | 0:11f19153c7da | 44 | } |
sampleCode | 0:11f19153c7da | 45 | |
sampleCode | 0:11f19153c7da | 46 | } |