code update
This commit is contained in:
18
MilliOhmMeter_FW/src/board.cpp
Normal file
18
MilliOhmMeter_FW/src/board.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "board.h"
|
||||
#include "Arduino.h"
|
||||
|
||||
void VextOn(void)
|
||||
{
|
||||
//Heltec.begin(true,false,true);
|
||||
pinMode(Vext,OUTPUT);
|
||||
digitalWrite(Vext, LOW);
|
||||
}
|
||||
|
||||
void initBoard(void)
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.flush();
|
||||
Serial.print("Init Board: ");
|
||||
VextOn();
|
||||
Serial.println("OK");
|
||||
}
|
||||
3
MilliOhmMeter_FW/src/board.h
Normal file
3
MilliOhmMeter_FW/src/board.h
Normal file
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
void initBoard(void);
|
||||
210
MilliOhmMeter_FW/src/display.cpp
Normal file
210
MilliOhmMeter_FW/src/display.cpp
Normal file
@@ -0,0 +1,210 @@
|
||||
#include "display.h"
|
||||
|
||||
SSD1306Wire display(0x3c, SDA_OLED, SCL_OLED, RST_OLED, GEOMETRY_128_64);
|
||||
;
|
||||
OLEDDisplayUi ui(&display);
|
||||
displayState displaystate = mainscreen;
|
||||
bool stateMutex = true;
|
||||
|
||||
String measureModes[4] = {"20mA", "200mA", "1000mA", "Auto"};
|
||||
uint8_t measureModePos[4] = {2, 34, 66, 98};
|
||||
uint8_t measureModeCenter[4] = {16, 48, 80, 112};
|
||||
|
||||
void drawWifiSymbol(OLEDDisplay *display, OLEDDisplayUiState *state)
|
||||
{
|
||||
}
|
||||
|
||||
c_displayMeasureMode ma20(mA20, 16, 32, "20m");
|
||||
c_displayMeasureMode ma200(mA200, 48, 32, "200m");
|
||||
c_displayMeasureMode ma1000(mA1000, 80, 32, "1A");
|
||||
c_displayMeasureMode mauto(mAuto, 112, 32, "Auto");
|
||||
|
||||
std::vector<c_displayMeasureMode> modes;
|
||||
|
||||
void initModes(void)
|
||||
{
|
||||
modes.push_back(ma20);
|
||||
modes.push_back(ma200);
|
||||
modes.push_back(ma1000);
|
||||
modes.push_back(mauto);
|
||||
}
|
||||
|
||||
void c_displayMeasureMode::drawMeasureMode(OLEDDisplay *display, measureMode mode, int16_t x, int16_t y)
|
||||
{
|
||||
display->setFont(ArialMT_Plain_10);
|
||||
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
||||
display->drawString(x + _xpos, y + CONTROLSTRIP_YPOS, _name);
|
||||
if (mode == _mode)
|
||||
{
|
||||
display->drawRect(x + (_xpos - (_width / 2)), y + CONTROLSLINE_YPOS, CONTROLSLINE_W, CONTROLSLINE_H);
|
||||
}
|
||||
else
|
||||
{
|
||||
display->fillRect(x + (_xpos - (_width / 2)), y + CONTROLSLINE_YPOS, CONTROLSLINE_W, CONTROLSLINE_H);
|
||||
}
|
||||
}
|
||||
|
||||
String showValue(String designator, double value, String unit)
|
||||
{
|
||||
String text;
|
||||
text.clear();
|
||||
if (designator != "")
|
||||
{
|
||||
text = designator;
|
||||
}
|
||||
text += value;
|
||||
text += unit;
|
||||
return text;
|
||||
}
|
||||
|
||||
void drawMeasurementValues(OLEDDisplay *display, int16_t x, int16_t y)
|
||||
{
|
||||
display->setFont(ArialMT_Plain_10);
|
||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||
display->drawString(x + 0, y + 0, showValue("m:", getMin(), ""));
|
||||
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
||||
display->drawString(x + 64, y + 0, showValue("r:", getRms(), ""));
|
||||
display->setTextAlignment(TEXT_ALIGN_RIGHT);
|
||||
display->drawString(x + 128, y + 0, showValue("m:", getMax(), ""));
|
||||
|
||||
display->setFont(ArialMT_Plain_24);
|
||||
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
||||
|
||||
display->drawString(x + 64, y + 12, showValue("", getValue(), "mE"));
|
||||
display->drawProgressBar(x + 0, y + 40, 127, 5, getBar());
|
||||
}
|
||||
|
||||
void drawButtons(OLEDDisplay *display, int16_t x, int16_t y)
|
||||
{
|
||||
//draw controlstrip indicators
|
||||
measureMode currentMode = getMeasureMode();
|
||||
|
||||
for (auto &&thismode : modes)
|
||||
{
|
||||
thismode.drawMeasureMode(display, currentMode, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
int screenW = 128;
|
||||
int screenH = 64;
|
||||
int clockCenterX = screenW / 2;
|
||||
int clockCenterY = ((screenH - 16) / 2) + 16; // top yellow part is 16 px height
|
||||
int clockRadius = 23;
|
||||
|
||||
void drawMeasurementDail(OLEDDisplay *display, int16_t x, int16_t y)
|
||||
{
|
||||
//fit half a circle on screen
|
||||
display->drawCircleQuads(DAILCENTERX, DAILCENTERY, DAILRADIUS + 1, 0b0011);
|
||||
display->drawCircleQuads(DAILCENTERX, DAILCENTERY, DAILRADIUS, 0b0011);
|
||||
|
||||
//draw outer ticks
|
||||
for (int z = -90; z < 91; z = z + 30)
|
||||
{
|
||||
//Begin at 0° and stop at 360°
|
||||
float angle = z;
|
||||
angle = (angle / 57.29577951); //Convert degrees to radians
|
||||
int x2 = (DAILCENTERX + (sin(angle) * DAILRADIUS));
|
||||
int y2 = (DAILCENTERY - (cos(angle) * DAILRADIUS));
|
||||
int x3 = (DAILCENTERX + (sin(angle) * (DAILRADIUS - 8)));
|
||||
int y3 = (DAILCENTERY - (cos(angle) * (DAILRADIUS - 8)));
|
||||
display->drawLine(x2 + x, y2 + y, x3 + x, y3 + y);
|
||||
}
|
||||
//draw inner Ticks
|
||||
for (int z = -75; z < 76; z = z + 30)
|
||||
{
|
||||
//Begin at 0° and stop at 360°
|
||||
float angle = z;
|
||||
angle = (angle / 57.29577951); //Convert degrees to radians
|
||||
int x2 = (DAILCENTERX + (sin(angle) * DAILRADIUS));
|
||||
int y2 = (DAILCENTERY - (cos(angle) * DAILRADIUS));
|
||||
int x3 = (DAILCENTERX + (sin(angle) * (DAILRADIUS - 4)));
|
||||
int y3 = (DAILCENTERY - (cos(angle) * (DAILRADIUS - 4)));
|
||||
display->drawLine(x2 + x, y2 + y, x3 + x, y3 + y);
|
||||
}
|
||||
|
||||
// draw value
|
||||
float angle = map(getValue(), 270, 90, 0, 100);
|
||||
angle = (angle / 57.29577951); //Convert degrees to radians
|
||||
int x3 = (DAILCENTERX + (sin(angle) * (DAILRADIUS - (DAILRADIUS / 5))));
|
||||
int y3 = (DAILCENTERY - (cos(angle) * (DAILRADIUS - (DAILRADIUS / 5))));
|
||||
display->drawLine(DAILCENTERX + x, DAILCENTERY + y, x3 + x, y3 + y);
|
||||
}
|
||||
|
||||
void drawMainScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
||||
{
|
||||
|
||||
if ((displaystate != mainscreen) && (x == 0))
|
||||
{
|
||||
Serial.printf("[%lu] display: DrawMainScreen\n", millis());
|
||||
displaystate = mainscreen;
|
||||
}
|
||||
|
||||
drawButtons(display, x, y);
|
||||
//drawMeasurementValues(display, x, y);
|
||||
drawMeasurementDail(display, x, y);
|
||||
}
|
||||
|
||||
void drawSetupScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
||||
{
|
||||
// draw an xbm image.
|
||||
// Please note that everything that should be transitioned
|
||||
// needs to be drawn relative to x and y
|
||||
display->setFont(ArialMT_Plain_16);
|
||||
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
||||
display->drawString(x + 64, y + 0, "Setup screen");
|
||||
if ((displaystate != setupscreen) && (x == 0))
|
||||
{
|
||||
Serial.printf("[%lu] display: DrawSetupScreen\n", millis());
|
||||
displaystate = setupscreen;
|
||||
}
|
||||
}
|
||||
|
||||
FrameCallback frames[] = {drawMainScreen}; //, drawSetupScreen};
|
||||
int frameCount = 1;
|
||||
OverlayCallback overlays[] = {drawWifiSymbol};
|
||||
int overlaysCount = 1;
|
||||
bool displayInitDone = false;
|
||||
|
||||
void initDisplay(void)
|
||||
{
|
||||
Serial.print("Init Display: ");
|
||||
|
||||
initModes();
|
||||
|
||||
displayInitDone = true;
|
||||
|
||||
ui.setTargetFPS(30);
|
||||
|
||||
// You can change this to
|
||||
// TOP, LEFT, BOTTOM, RIGHT
|
||||
ui.setIndicatorPosition(BOTTOM);
|
||||
|
||||
// Defines where the first frame is located in the bar.
|
||||
ui.setIndicatorDirection(LEFT_RIGHT);
|
||||
|
||||
// You can change the transition that is used
|
||||
// SLIDE_LEFT, SLIDE_RIGHT, SLIDE_UP, SLIDE_DOWN
|
||||
ui.setFrameAnimation(SLIDE_LEFT);
|
||||
|
||||
// Add frames
|
||||
ui.setFrames(frames, frameCount);
|
||||
|
||||
// Add overlays
|
||||
ui.setOverlays(overlays, overlaysCount);
|
||||
|
||||
ui.disableAllIndicators();
|
||||
ui.disableAutoTransition();
|
||||
|
||||
// Initialising the UI will init the display too.
|
||||
ui.init();
|
||||
Serial.println(" OK");
|
||||
}
|
||||
|
||||
void handleDisplay(void)
|
||||
{
|
||||
if (!displayInitDone)
|
||||
return;
|
||||
int remainingTimeBudget = ui.update();
|
||||
|
||||
Serial.printf("DT=%u;", remainingTimeBudget);
|
||||
}
|
||||
34
MilliOhmMeter_FW/src/display.h
Normal file
34
MilliOhmMeter_FW/src/display.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
#include "SSD1306Wire.h"
|
||||
#include "OLEDDisplayUi.h"
|
||||
#include "measure.h"
|
||||
|
||||
#include "image.h"
|
||||
|
||||
#define CONTROLSTRIP_YPOS 63 - 10 - 4
|
||||
#define CONTROLSLINE_YPOS 60
|
||||
#define CONTROLSLINE_H 4
|
||||
#define CONTROLSLINE_W 30
|
||||
#define DAILRADIUS 45
|
||||
#define DAILCENTERX 128/2
|
||||
#define DAILCENTERY DAILRADIUS+1
|
||||
|
||||
enum displayState
|
||||
{
|
||||
mainscreen,
|
||||
setupscreen
|
||||
};
|
||||
|
||||
class c_displayMeasureMode
|
||||
{
|
||||
public:
|
||||
const measureMode _mode;
|
||||
const uint16_t _xpos;
|
||||
const uint16_t _width;
|
||||
const String _name;
|
||||
c_displayMeasureMode(measureMode mode, uint16_t xpos, uint16_t width, String name) : _mode(mode), _xpos(xpos), _width(width), _name(name) {}
|
||||
void drawMeasureMode(OLEDDisplay *display, measureMode mode, int16_t x, int16_t y);
|
||||
};
|
||||
|
||||
void initDisplay(void);
|
||||
void handleDisplay(void);
|
||||
68
MilliOhmMeter_FW/src/image.h
Normal file
68
MilliOhmMeter_FW/src/image.h
Normal file
@@ -0,0 +1,68 @@
|
||||
#include "Arduino.h"
|
||||
|
||||
static const unsigned char PROGMEM VUMeter[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x03, 0x00, 0x60, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x09, 0x04, 0x80, 0x21, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x01, 0x98, 0x08, 0x06, 0x03, 0x80, 0x21, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xA4, 0x10, 0x09, 0x00, 0x80, 0x21, 0x20, 0x07, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xA4, 0x10, 0x06, 0x03, 0x00, 0x20, 0xC0, 0x00, 0x80, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x71, 0x80, 0xA4, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x0A, 0x40, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3C, 0x00, 0x00,
|
||||
0x00, 0x00, 0x3A, 0x40, 0x00, 0x00, 0x02, 0x01, 0x00, 0x40, 0x80, 0x07, 0x00, 0x20, 0x00, 0x00,
|
||||
0x00, 0x00, 0x42, 0x40, 0x00, 0x08, 0x02, 0x01, 0x08, 0x40, 0x80, 0x00, 0x00, 0x38, 0x00, 0x00,
|
||||
0x00, 0x00, 0x79, 0x80, 0x04, 0x08, 0x02, 0x01, 0x08, 0x81, 0x10, 0x00, 0x00, 0x04, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x04, 0x08, 0x02, 0x01, 0x08, 0x81, 0x11, 0x04, 0x00, 0x38, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x02, 0x01, 0x08, 0x81, 0x21, 0x04, 0x00, 0x00, 0x08, 0x00,
|
||||
0x00, 0x00, 0x00, 0x84, 0x02, 0x04, 0x0F, 0xFF, 0xFF, 0xC3, 0xE2, 0x04, 0x00, 0x00, 0x08, 0x00,
|
||||
0x00, 0x00, 0x00, 0xC2, 0x01, 0x07, 0xF0, 0x00, 0x00, 0x3B, 0xFE, 0x08, 0x40, 0x40, 0x08, 0x00,
|
||||
0x00, 0xFE, 0x00, 0x62, 0x01, 0xF8, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xE8, 0x40, 0x80, 0x7F, 0x00,
|
||||
0x00, 0x00, 0x00, 0x21, 0x1E, 0x00, 0x04, 0x00, 0x80, 0x00, 0x7F, 0xFE, 0x80, 0x80, 0x08, 0x00,
|
||||
0x00, 0x00, 0x03, 0x31, 0xE0, 0x00, 0x04, 0x00, 0x80, 0x04, 0x01, 0xFF, 0xC1, 0x00, 0x08, 0x00,
|
||||
0x00, 0x00, 0x07, 0x1E, 0x00, 0x40, 0x00, 0x00, 0x00, 0x04, 0x00, 0x1F, 0xFA, 0x00, 0x08, 0x00,
|
||||
0x00, 0x00, 0x07, 0xF0, 0x00, 0x40, 0x3B, 0x07, 0x60, 0x00, 0x00, 0x01, 0xFF, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x34, 0x81, 0x90, 0xCC, 0xC0, 0x00, 0x3F, 0xC0, 0x00, 0x00,
|
||||
0x00, 0x00, 0x0C, 0x00, 0x03, 0x30, 0x0C, 0x82, 0x90, 0x53, 0x20, 0x00, 0x07, 0xF8, 0x00, 0x00,
|
||||
0x00, 0x00, 0x70, 0x40, 0x00, 0xC8, 0x3B, 0x02, 0x60, 0x53, 0x20, 0x00, 0x00, 0xFE, 0x00, 0x00,
|
||||
0x00, 0x01, 0x80, 0x20, 0x01, 0xC8, 0x00, 0x00, 0x00, 0x4C, 0xC0, 0x00, 0x00, 0x3F, 0x80, 0x00,
|
||||
0x00, 0x06, 0x00, 0x00, 0x03, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xE0, 0x00,
|
||||
0x00, 0x08, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFC, 0x00,
|
||||
0x00, 0x30, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00,
|
||||
0x00, 0x00, 0x40, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
|
||||
0x00, 0x00, 0xA0, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x02, 0x02, 0x30, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x03, 0x06, 0x30, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x8C, 0x30, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0xD8, 0x30, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x70, 0x19, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x20, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
24
MilliOhmMeter_FW/src/leds.cpp
Normal file
24
MilliOhmMeter_FW/src/leds.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include "leds.h"
|
||||
|
||||
uint64_t lastLedTimer = 0;
|
||||
bool ledBlinkState = false;
|
||||
|
||||
void initLeds(void)
|
||||
{
|
||||
Serial.print("Init Leds: ");
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, ledBlinkState );
|
||||
lastLedTimer = millis();
|
||||
Serial.println("OK");
|
||||
}
|
||||
|
||||
void handleLeds(void)
|
||||
{
|
||||
uint64_t currentTime = millis();
|
||||
if(currentTime - lastLedTimer > LEDINTERVAL)
|
||||
{
|
||||
digitalWrite(LED_BUILTIN, ledBlinkState);
|
||||
ledBlinkState = !ledBlinkState;
|
||||
lastLedTimer = currentTime;
|
||||
}
|
||||
}
|
||||
10
MilliOhmMeter_FW/src/leds.h
Normal file
10
MilliOhmMeter_FW/src/leds.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "board.h"
|
||||
|
||||
|
||||
#define LEDINTERVAL 1000
|
||||
|
||||
void initLeds(void);
|
||||
void handleLeds(void);
|
||||
29
MilliOhmMeter_FW/src/main.cpp
Normal file
29
MilliOhmMeter_FW/src/main.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <Arduino.h>
|
||||
#include "board.h"
|
||||
#include "display.h"
|
||||
#include "leds.h"
|
||||
#include "measure.h"
|
||||
|
||||
uint64_t looptime = 0;
|
||||
|
||||
void setup()
|
||||
{
|
||||
// put your setup code here, to run once:
|
||||
initBoard();
|
||||
initDisplay();
|
||||
initLeds();
|
||||
initMeasure();
|
||||
looptime = millis();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// put your main code here, to run repeatedly:
|
||||
looptime = micros();
|
||||
|
||||
handleDisplay();
|
||||
handleLeds();
|
||||
handleMeasure();
|
||||
|
||||
Serial.printf("T=%4.2f\n", (double)(micros() - looptime)/1000);
|
||||
}
|
||||
40
MilliOhmMeter_FW/src/measure.cpp
Normal file
40
MilliOhmMeter_FW/src/measure.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include "measure.h"
|
||||
|
||||
void initMeasure( void )
|
||||
{
|
||||
|
||||
}
|
||||
void handleMeasure (void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
measureMode getMeasureMode( void )
|
||||
{
|
||||
return measureMode::mA200;
|
||||
}
|
||||
|
||||
double getMin( void)
|
||||
{
|
||||
return 14.4;
|
||||
}
|
||||
|
||||
double getMax(void)
|
||||
{
|
||||
return 234.8;
|
||||
}
|
||||
|
||||
double getRms(void)
|
||||
{
|
||||
return 146.7;
|
||||
}
|
||||
|
||||
uint8_t getBar(void)
|
||||
{
|
||||
return 68;
|
||||
}
|
||||
|
||||
double getValue(void)
|
||||
{
|
||||
return 144.8;
|
||||
}
|
||||
24
MilliOhmMeter_FW/src/measure.h
Normal file
24
MilliOhmMeter_FW/src/measure.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "Arduino.h"
|
||||
|
||||
enum measureMode
|
||||
{
|
||||
mA20,
|
||||
mA200,
|
||||
mA1000,
|
||||
mAuto
|
||||
};
|
||||
|
||||
void initMeasure( void );
|
||||
void handleMeasure (void );
|
||||
|
||||
measureMode getMeasureMode( void );
|
||||
|
||||
measureMode getMeasureMode( void );
|
||||
|
||||
double getMin( void);
|
||||
double getMax(void);
|
||||
double getRms(void);
|
||||
uint8_t getBar(void);
|
||||
double getValue(void);
|
||||
Reference in New Issue
Block a user