//#include <Arduino.h>
//Display libary and Display type
#include <U8g2lib.h>
#include <SPI.h>
// Display auswählen //////////////
//U8G2_SSD1309_128X64_NONAME0_F_4W_HW_SPI u8g21(U8G2_R0, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5);
U8G2_SSD1306_128X64_ALT0_F_HW_I2C u8g21(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // same as the NONAME variant, but may solve the "every 2nd line skipped" problem
//U8G2_SSD1309_128X64_NONAME2_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
//
#include <Adafruit_NeoPixel.h>
//Adafruit_NeoPixel pixels(16, 2, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip(16, 2, NEO_GRB + NEO_KHZ800);
//
//
// init values
//
int SPEED = 0;
int ENGINE_RUNTIME = 0;
int COOLANT_TEMP = 96;
int ENGINE_LOAD = 0;
int ENGINE_RPM = 200;
// setup for core 0
// core 0 drives the Head-up display and connects to OBD-II adapter to recive vehicle data
void setup()
{
// Set SPI-pins for second display
//SPI.setTX(19);
//SPI.setSCK(18);
//
// init serial connection
//Serial.begin(115200)
//
strip.begin();
strip.show(); // Initialize all pixels to 'off'
// pixels.begin();
// // init u8g2 big Head up Display
u8g21.begin(); //begin connection display
u8g21.clearBuffer(); //clear Buffer at begin
//u8g21.setDisplayRotation(U8G2_MIRROR); //Mirrors display for reflection to be straigth
//u8g21.setDisplayRotation(U8G2_R2); //rotate display 180 degrees
//u8g21.drawXBM( 0, 0, 128, 64, raspberrylogo); //draw bitmap
//u8g21.sendBuffer();
//delay(3000); //display logo for 3s before initialisation
u8g21.clearBuffer();
u8g21.setCursor(1,10);
u8g21.setFont(u8g2_font_smart_patrol_nbp_tr); //u8g2_font_smart_patrol_nbp_tr u8g2_font_bubble_tn
u8g21.print("Display init...");
u8g21.setCursor(100,10);
u8g21.print("ok");
u8g21.sendBuffer();
//
// init OBD-connection
//print on display that connection is being initiated
u8g21.setCursor(1,24);
u8g21.print("OBD init... ");
u8g21.sendBuffer();
//wait until connection is ready
//print that connection to OBDII adapter is sucessful
u8g21.setCursor(100,24);
u8g21.print("ok");
u8g21.sendBuffer();
delay(1000);
//for(int i=0; i<16; i++) { // For each pixel...
// pixels.Color() takes RGB values, from 0,0,0 up to 255,255,255
// Here we're using a moderately bright green color:
//pixels.setPixelColor(i, pixels.Color(150, 150, 0));
//pixels.show(); // Send the updated pixel colors to the hardware.
// Pause before next pass through loop
//}
//
}
// loop core 0
void loop()
{
// pixels.clear();
// read PIDs from OBDII adapter
// set leds to red
u8g21.clearBuffer();
u8g21.setFont(u8g2_font_smart_patrol_nbp_tr); //u8g2_font_smart_patrol_nbp_tr u8g2_font_bubble_tn
u8g21.setCursor(28,22);
u8g21.print("HIGH TEMP");
u8g21.setCursor(38,46);
u8g21.setFont(u8g2_font_crox5h_tr);
u8g21.print(COOLANT_TEMP);
u8g21.print("*C");
u8g21.setCursor(2,60);
u8g21.setFont(u8g2_font_6x10_tf );
u8g21.print(20);
u8g21.print(" km/h");
u8g21.setCursor(90,60);
u8g21.setFont(u8g2_font_6x10_tf );
u8g21.print(87);
u8g21.print(" C*");
u8g21.sendBuffer();
strip.fill(strip.ColorHSV(0, 255, 255));
strip.show();
delay (142);
u8g21.setFont(u8g2_font_smart_patrol_nbp_tr); //u8g2_font_smart_patrol_nbp_tr u8g2_font_bubble_tn
u8g21.setCursor(30,12);
u8g21.print("WARNING!!!!!");
u8g21.sendBuffer();
// turn off lights to become blinking red effect
strip.clear();
strip.show();
// displaying text on Head up Display
//uint32_t rgbcolor = strip.ColorHSV(hue, saturation, value);
// uint32_t rgbcolor = strip.ColorHSV(hue);
//strip.fill(rgbcolor);
//strip.show();
//
}
//