add oled display
This commit is contained in:
parent
3f78a5b8f2
commit
44469d88c1
|
@ -121,4 +121,6 @@ bool armed = false; //cmd output values forced to 0 if false
|
|||
#define CURRENT_FILTER_SIZE 60 //latency is about CURRENT_FILTER_SIZE/2*MEASURE_INTERVAL (measure interval is defined by hoverboard controller)
|
||||
#define CURRENT_MEANVALUECOUNT 20 //0<= meanvaluecount < CURRENT_FILTER_SIZE/2. how many values will be used from sorted weight array from the center region. abour double this values reading are used
|
||||
|
||||
#define DISPLAYUPDATEPERIOD 100
|
||||
|
||||
#endif
|
|
@ -0,0 +1,38 @@
|
|||
#ifndef _DISPLAY_H_
|
||||
#define _DISPLAY_H_
|
||||
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_SSD1306.h>
|
||||
|
||||
#define SCREEN_WIDTH 128 // OLED display width, in pixels
|
||||
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
|
||||
|
||||
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
|
||||
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
|
||||
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
|
||||
|
||||
void display_init();
|
||||
void display_test();
|
||||
|
||||
void display_init(){
|
||||
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
|
||||
Serial.println(F("SSD1306 allocation failed"));
|
||||
}
|
||||
display.clearDisplay();
|
||||
display.display();
|
||||
}
|
||||
|
||||
void display_test(){
|
||||
display.clearDisplay();
|
||||
display.setTextSize(1); // Normal 1:1 pixel scale
|
||||
display.setTextColor(SSD1306_WHITE); // Draw white text
|
||||
display.setCursor(0,0); // Start at top-left corner
|
||||
display.println(F("Hello Welt"));
|
||||
display.println(millis());
|
||||
display.println(now());
|
||||
display.display();
|
||||
}
|
||||
|
||||
|
||||
#endif
|
|
@ -22,3 +22,4 @@ build_flags =
|
|||
|
||||
lib_deps =
|
||||
robtillaart/ADS1X15@^0.3.9
|
||||
adafruit/Adafruit SSD1306@^2.5.7
|
|
@ -1,11 +1,11 @@
|
|||
#include <Arduino.h>
|
||||
|
||||
|
||||
#include "definitions.h"
|
||||
#include "structs.h"
|
||||
#include "helpfunctions.h"
|
||||
#include <TimeLib.h> //for teensy rtc
|
||||
#include "comms.h"
|
||||
#include "display.h"
|
||||
|
||||
#include "ADS1X15.h"
|
||||
|
||||
|
@ -22,12 +22,6 @@ Tennsy Pin, Pin Name, Connected to
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void readADS();
|
||||
void readADC();
|
||||
void failChecks();
|
||||
|
@ -70,6 +64,9 @@ void setup()
|
|||
digitalWrite(PIN_LATCH_ENABLE,HIGH); //latch on
|
||||
pinMode(PIN_MODE_SWITCH, INPUT_PULLUP);
|
||||
|
||||
|
||||
display_init();
|
||||
|
||||
delay(2000);
|
||||
Serial.println("Wait finished. Booting..");
|
||||
|
||||
|
@ -184,7 +181,11 @@ void loop() {
|
|||
|
||||
leds();
|
||||
|
||||
|
||||
static unsigned long last_display_update=0;
|
||||
if (loopmillis - last_display_update > DISPLAYUPDATEPERIOD) {
|
||||
last_display_update=loopmillis;
|
||||
display_test();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue