summaryrefslogtreecommitdiff
path: root/HelloWorld/HelloWorld.ino
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2021-12-18 11:45:26 +0200
committerYuval Adam <_@yuv.al>2021-12-18 11:45:26 +0200
commitc1331d40912bc808f927c2f742da44530039123e (patch)
treed4dbecd20686dd764569a7a900b4984c8e0e8346 /HelloWorld/HelloWorld.ino
parent74b082c851303ff0a87b492c5f3c40759d1fd40c (diff)
Add lots of graphics libs and show axl readings
Diffstat (limited to 'HelloWorld/HelloWorld.ino')
-rw-r--r--HelloWorld/HelloWorld.ino48
1 files changed, 47 insertions, 1 deletions
diff --git a/HelloWorld/HelloWorld.ino b/HelloWorld/HelloWorld.ino
index ad56df4..defcab1 100644
--- a/HelloWorld/HelloWorld.ino
+++ b/HelloWorld/HelloWorld.ino
@@ -1,6 +1,16 @@
-#include"TFT_eSPI.h"
+#include "TFT_eSPI.h"
+#include "ADXL335.h"
+#include "seeed_graphics_define.h"
+#include "seeed_graphics_base.h"
+#include "seeed_line_chart.h"
TFT_eSPI tft;
+ADXL335 axl;
+
+#define max_size 50
+
+doubles accelerator_readings[3];
+TFT_eSprite spr = TFT_eSprite(&tft);
void setup() {
tft.begin();
@@ -10,8 +20,44 @@ void setup() {
tft.setTextSize(4);
tft.drawString("Hello world!", 20, 100);
+ spr.createSprite(TFT_HEIGHT, TFT_WIDTH);
+
+ axl.begin();
}
void loop() {
+ spr.fillSprite(TFT_WHITE);
+ float ax = axl.getAccelerationX();
+ float ay = axl.getAccelerationY();
+ float az = axl.getAccelerationZ();
+
+ if (accelerator_readings[0].size() == max_size) {
+ for (uint8_t i = 0; i<3; i++){
+ accelerator_readings[i].pop();
+ }
+ }
+ accelerator_readings[0].push(ax);
+ accelerator_readings[1].push(ay);
+ accelerator_readings[2].push(az);
+
+ auto header = text(0, 0);
+ header.value("Acceleration Readings");
+ header.align(center);
+ header.valign(vcenter);
+ header.width(tft.width());
+ header.thickness(2);
+ header.height(header.font_height() * 2);
+ header.draw();
+
+ auto content = line_chart(20, header.height());
+ content.height(tft.height() - header.height() * 1.5);
+ content.width(tft.width() - content.x() * 2);
+ content.based_on(-2.0);
+ content.show_circle(false);
+ content.value({accelerator_readings[0],accelerator_readings[1], accelerator_readings[2]});
+ content.color(TFT_BLUE, TFT_RED, TFT_GREEN);
+ content.draw();
+ spr.pushSprite(0, 0);
+ delay(50);
}