Small project to display some OBD values from the Toyota GT86/ Subaru BRZ/ Scion FRS on an OLED display.

Dependencies:   Adafruit_GFX MODSERIAL mbed-rtos mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers display.cpp Source File

display.cpp

00001 #include "display.h"
00002 
00003 Display::SPI2::SPI2(PinName mosi, PinName miso, PinName clk)
00004 : SPI(mosi, miso, clk)
00005 {
00006     format(8,3);
00007     frequency(2000000);
00008 };
00009 
00010 
00011 Display::Display()
00012 : m_spi(p5, NC, p7)
00013 , m_oled(m_spi, p18, p19, p20)
00014 {
00015 }
00016 
00017     
00018 void Display::clear()
00019 {
00020     m_oled.clearDisplay();
00021 }
00022     
00023 void Display::display()
00024 {
00025     m_oled.display();
00026 }
00027 
00028 void Display::sendTo(const char* text)
00029 {
00030     uint8_t line = 0;
00031     if (strstr(text, "RPM"))
00032     {
00033         line = 1;
00034     }
00035     else if (strstr(text, "Oil"))
00036     {
00037         line = 2;
00038     }
00039     else if (strstr(text, "Coolant"))
00040     {
00041         line = 3;
00042     }
00043     else if (strstr(text, "Speed")) 
00044     {
00045         return;
00046     }
00047     
00048     m_oled.setCursor(0, line * 8);
00049     m_oled.printf("%s", text);
00050 
00051 }