From aad760c0397bf45cfe711fcd3b772c520229a5d1 Mon Sep 17 00:00:00 2001 From: Maximilian Friedersdorff Date: Thu, 23 Jun 2022 21:08:02 +0100 Subject: [PATCH] Fix unit letters, enable internal pullup resistors --- battery_tester.ino | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/battery_tester.ino b/battery_tester.ino index 9b7865a..3b9b762 100644 --- a/battery_tester.ino +++ b/battery_tester.ino @@ -22,8 +22,8 @@ const bool nine[7] = {true, true, true, true, false, true, true}; const bool zero[7] = {true, true, true, true, true, true, false}; const bool U[7] = {false, true, true, true, true, true, false}; -const bool I[7] = {false, false, true, false, false, false, false}; -const bool P[7] = {true, true, false, false, true, true, true}; +const bool A[7] = {true, true, true, false, true, true, true}; +const bool E[7] = {true, false, false, true, true, true, true}; unsigned char display_state = 0; @@ -76,7 +76,7 @@ void writeDigit(char d, char val, bool dec) { } for (int i = 0; i < 7; ++i) { if (segs[i]) { - digitalWrite(segments[i], HIGH); + digitalWrite(segments[i], HIGH); } else { digitalWrite(segments[i], LOW); } @@ -118,12 +118,13 @@ void showVoltage(float volts) { writeDigit(2, cvolts % 10, false); writeLetter(3, U); } + void showCurrent(float current) { int camp = current * 100; writeDigit(0, (camp/100U) % 10, true); writeDigit(1, (camp/10U) % 10, false); writeDigit(2, camp % 10, false); - writeLetter(3, I); + writeLetter(3, A); } void showWh(float watthours) { @@ -131,7 +132,7 @@ void showWh(float watthours) { writeDigit(0, (w/1000U) % 10, true); writeDigit(1, (w/100U) % 10, false); writeDigit(2, (w/10U) % 10, false); - writeLetter(3, P); + writeLetter(3, E); } @@ -152,9 +153,9 @@ void setup() { pinMode(15, OUTPUT); digitalWrite(15, LOW); - pinMode(19, INPUT); - pinMode(20, INPUT); - pinMode(21, INPUT); + pinMode(19, INPUT_PULLUP); + pinMode(20, INPUT_PULLUP); + pinMode(21, INPUT_PULLUP); } void loop() { -- 2.46.2