#include <GxEPD.h>
#include <GxGDEP015OC1/GxGDEP015OC1.h>
#include <GxIO/GxIO_SPI/GxIO_SPI.h>
#include <GxIO/GxIO.h>
#include <Fonts/FreeSansBold24pt7b.h>
boolean METRIC = true; //Set true for metric system; false for imperial
float previousTemperature = -100.0;
float temperature = 0;
float weight = 0;
float weight1 = 0;
float weight2= 0;
float weight3 = 0;
float weight4 = 0;
GxIO_Class io(SPI, SS, 22, 21);
GxEPD_Class display(io, 16, 4);
int sensorValue = 0;
int sensorValue1 = 0;
int sensorValue2 = 0;
int sensorValue3 = 0;
int sensorValue4 = 0;
int total=0;
#include GxEPD_BitmapExamples
// FreeFonts from Adafruit_GFX
#include <Fonts/FreeMonoBold9pt7b.h>
#include <Fonts/FreeMonoBold12pt7b.h>
#include <Fonts/FreeMonoBold18pt7b.h>
#include <Fonts/FreeMonoBold24pt7b.h>
void setup()
{
Serial.begin(115200);
Serial.println();
Serial.println("setup");
display.init(115200); // enable diagnostic output on Serial
#if defined(__AVR) || false
display.drawPaged(drawHelloWorld);
#elif (defined(_GxGDEW075Z09_H_) || defined(_GxGDEW075Z08_H_)) && (defined(ESP8266) || defined(ARDUINO_ARCH_STM32F1))
display.drawPaged(drawHelloWorld);
#elif defined(_GxGDEW075Z09_H_)
display.drawPaged(drawHelloWorld);
#else
drawHelloWorld();
display.update();
#endif
Serial.println("setup done");
}
void loop(){
drawHelloWorldForDummies();
display.update();
sensorValue = analogRead(34);
sensorValue1 = analogRead(35);
sensorValue2 = analogRead(33);
sensorValue3 = analogRead(32);
sensorValue4 = analogRead(25);
weight = map(sensorValue, 0, 4095, 0, 2000);
weight1 = map(sensorValue1, 0, 4095, 0, 2000);
weight2= map(sensorValue2, 0, 4095, 0, 2000);
weight3 = map(sensorValue3, 0, 4095, 0, 2000);
weight4 = map(sensorValue4, 0, 4095, 0, 2000);
Serial.println(weight );
delay(1);
Serial.println(weight1 );
delay(1);
Serial.println(weight2 );
delay(1);
Serial.println(weight3 );
delay(1);
Serial.println(weight4 );
delay(1);
total=weight + weight1 + weight2 + weight3 + weight4;
}
const char HelloWorld[] = "Hello World!";
void drawHelloWorld()
{
//Serial.println("drawHelloWorld");
display.setRotation(1);
display.setFont(&FreeMonoBold9pt7b);
display.setTextColor(GxEPD_BLACK);
int16_t tbx, tby; uint16_t tbw, tbh;
display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
// center bounding box by transposition of origin:
uint16_t x = ((display.width() - tbw) / 2) - tbx;
uint16_t y = ((display.height() - tbh) / 2) - tby;
display.fillScreen(GxEPD_WHITE);
display.setCursor(x, y);
display.print(HelloWorld);
//Serial.println("drawHelloWorld done");
}
void drawHelloWorldForDummies()
{
const char text[] = "Hello World!";
display.setRotation(1);
display.setFont(&FreeMonoBold9pt7b);
//display.setTextColor(GxEPD_BLACK);
int16_t tbx, tby; uint16_t tbw, tbh;
display.getTextBounds(text, 0, 0, &tbx, &tby, &tbw, &tbh);
uint16_t x = ((display.width() - tbw) / 2) - tbx;
uint16_t y = ((display.height() - tbh) / 2) - tby;
display.fillScreen(GxEPD_WHITE);
display.setCursor(x, y);
display.print("s1 =");
display.println(weight);
display.print("TOTAL = ");
display.print(total); display.println(" Grams");
}Loading
epaper-2in9
epaper-2in9