Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a377b25e0 | ||
|
|
075459b890 | ||
|
|
bece16f012 | ||
|
|
14fa6e7fd0 | ||
|
|
4daa74bbfb | ||
|
|
4b74bc8988 | ||
|
|
f09e552e3d | ||
|
|
6de2e8728c | ||
|
|
60f08ea640 |
No files matched your search
+2
-2
@@ -9,8 +9,8 @@
|
|||||||
; https://docs.platformio.org/page/projectconf.html
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
[common]
|
[common]
|
||||||
version = "3.2.7-beta1"
|
version = "3.3.1"
|
||||||
to_old_version = "3.0.9"
|
to_old_version = "3.2.0"
|
||||||
|
|
||||||
##
|
##
|
||||||
[env:esp32dev]
|
[env:esp32dev]
|
||||||
|
|||||||
@@ -324,6 +324,7 @@ void sendRfidResultAsync(String tagUuid, int spoolId, int locationId, bool succe
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool initFilaman() {
|
bool initFilaman() {
|
||||||
|
oledShowProgressBar(3, NUM_SETUP_STEPS, DISPLAY_BOOT_TEXT, tr(STR_API_INIT));
|
||||||
loadFilamanConfig();
|
loadFilamanConfig();
|
||||||
queueMutex = xSemaphoreCreateMutex();
|
queueMutex = xSemaphoreCreateMutex();
|
||||||
// Move to Core 1 (Hardware Core) to free up Core 0 for WiFi/Webserver
|
// Move to Core 1 (Hardware Core) to free up Core 0 for WiFi/Webserver
|
||||||
|
|||||||
@@ -29,6 +29,8 @@
|
|||||||
#define DISPLAY_UPDATE_INTERVAL 1000U
|
#define DISPLAY_UPDATE_INTERVAL 1000U
|
||||||
#define FILAMAN_HEARTBEAT_INTERVAL 60000U
|
#define FILAMAN_HEARTBEAT_INTERVAL 60000U
|
||||||
|
|
||||||
|
#define NUM_SETUP_STEPS 6 // 0:Display 1:WiFi 2:Web-Server 3:API 4:NFC 5:Scale 6:<finished>
|
||||||
|
|
||||||
extern const uint8_t PN532_IRQ;
|
extern const uint8_t PN532_IRQ;
|
||||||
extern const uint8_t PN532_RESET;
|
extern const uint8_t PN532_RESET;
|
||||||
|
|
||||||
|
|||||||
+33
-11
@@ -115,7 +115,7 @@ void setupDisplay() {
|
|||||||
lastActivityMillis = millis();
|
lastActivityMillis = millis();
|
||||||
|
|
||||||
oledShowTopRow();
|
oledShowTopRow();
|
||||||
oledShowProgressBar(0, 7, DISPLAY_BOOT_TEXT, tr(STR_DISPLAY_INIT));
|
oledShowProgressBar(0, NUM_SETUP_STEPS, DISPLAY_BOOT_TEXT, tr(STR_DISPLAY_INIT));
|
||||||
}
|
}
|
||||||
|
|
||||||
void oledclearline() {
|
void oledclearline() {
|
||||||
@@ -250,6 +250,12 @@ void oledDisplayText(const String &message, uint8_t size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void oledShowTopRow() {
|
void oledShowTopRow() {
|
||||||
|
const u_int8_t rightmost_x = 108;
|
||||||
|
const u_int8_t x_offset = 25;
|
||||||
|
const u_int8_t symbol_width =16;
|
||||||
|
const u_int8_t symbol_height =16;
|
||||||
|
u_int8_t x_pos = rightmost_x;
|
||||||
|
|
||||||
oledclearline();
|
oledclearline();
|
||||||
|
|
||||||
display.setTextSize(1);
|
display.setTextSize(1);
|
||||||
@@ -259,27 +265,43 @@ void oledShowTopRow() {
|
|||||||
|
|
||||||
iconToggle = !iconToggle;
|
iconToggle = !iconToggle;
|
||||||
|
|
||||||
|
// draw symbols from right to left
|
||||||
// Do not show status indicators during boot
|
// Do not show status indicators during boot
|
||||||
if(!booting){
|
if(!booting){
|
||||||
if (filamanConnected) {
|
// WiFi
|
||||||
display.drawBitmap(80, 0, bitmap_spoolman_on , 16, 16, WHITE);
|
x_pos = rightmost_x;
|
||||||
|
if (wifiOn == 1) {
|
||||||
|
display.drawBitmap(x_pos, 0, wifi_on , symbol_width, symbol_height, WHITE);
|
||||||
} else {
|
} else {
|
||||||
if(iconToggle){
|
if(iconToggle){
|
||||||
display.drawBitmap(80, 0, bitmap_spoolman_on , 16, 16, WHITE);
|
display.drawBitmap(x_pos, 0, wifi_on , symbol_width, symbol_height, WHITE);
|
||||||
display.drawLine(80, 15, 96, 0, WHITE);
|
display.drawLine(x_pos, symbol_height-1, x_pos + symbol_width, 0, WHITE);
|
||||||
display.drawLine(81, 15, 97, 0, WHITE);
|
display.drawLine(x_pos+1, symbol_height-1, x_pos+1 + symbol_width, 0, WHITE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wifiOn == 1) {
|
// Backend
|
||||||
display.drawBitmap(107, 0, wifi_on , 16, 16, WHITE);
|
x_pos -= x_offset; // change x position to the left
|
||||||
|
if (filamanConnected) {
|
||||||
|
display.drawBitmap(x_pos, 0, bitmap_spoolman_on , symbol_width, symbol_height, WHITE);
|
||||||
} else {
|
} else {
|
||||||
if(iconToggle){
|
if(iconToggle){
|
||||||
display.drawBitmap(107, 0, wifi_on , 16, 16, WHITE);
|
display.drawBitmap(x_pos, 0, bitmap_spoolman_on , symbol_width, symbol_height, WHITE);
|
||||||
display.drawLine(107, 15, 123, 0, WHITE);
|
display.drawLine(x_pos, symbol_height-1, x_pos + symbol_width, 0, WHITE);
|
||||||
display.drawLine(108, 15, 124, 0, WHITE);
|
display.drawLine(x_pos+1, symbol_height-1, x_pos+1 + symbol_width, 0, WHITE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Scale
|
||||||
|
x_pos -= x_offset; // change x position to the left
|
||||||
|
if (scaleConnected) {
|
||||||
|
display.drawBitmap(x_pos, 0, bitmap_scale_on , symbol_width, symbol_height, WHITE);
|
||||||
|
} else {
|
||||||
|
display.drawBitmap(x_pos, 0, bitmap_scale_on , symbol_width, symbol_height, WHITE);
|
||||||
|
display.drawLine(x_pos-1, symbol_height-1, x_pos-1 + symbol_width, 0, WHITE);
|
||||||
|
display.drawLine(x_pos, symbol_height-1, x_pos + symbol_width, 0, WHITE);
|
||||||
|
display.drawLine(x_pos+1, symbol_height-1, x_pos+1 + symbol_width, 0, WHITE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
display.display();
|
display.display();
|
||||||
|
|||||||
@@ -37,6 +37,12 @@ const unsigned char bitmap_bambu_on [] PROGMEM = {
|
|||||||
0x30, 0x78, 0x00, 0x7c, 0x06, 0x7c, 0x1e, 0x7c, 0x3e, 0x7c, 0x3e, 0x7c, 0x3e, 0x7c, 0x3e, 0x7c
|
0x30, 0x78, 0x00, 0x7c, 0x06, 0x7c, 0x1e, 0x7c, 0x3e, 0x7c, 0x3e, 0x7c, 0x3e, 0x7c, 0x3e, 0x7c
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 'scale_on', 16x16px
|
||||||
|
const unsigned char bitmap_scale_on [] PROGMEM = {
|
||||||
|
0x01, 0x80, 0x3f, 0xfc, 0x3f, 0xfc, 0x11, 0x88, 0x21, 0x84, 0x09, 0x90, 0x49, 0x92, 0x45, 0xa2,
|
||||||
|
0x05, 0xa1, 0xff, 0xbf, 0xfd, 0xbf, 0x79, 0x9e, 0x01, 0x80, 0x01, 0x80, 0x0f, 0xf0, 0x0f, 0xf8
|
||||||
|
};
|
||||||
|
|
||||||
// 'failed', 47x47px
|
// 'failed', 47x47px
|
||||||
const unsigned char icon_failed [] PROGMEM = {
|
const unsigned char icon_failed [] PROGMEM = {
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xfc, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xfc, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff,
|
||||||
|
|||||||
@@ -10,8 +10,10 @@ Lang currentLang = LANG_EN;
|
|||||||
static const char EN_DISPLAY_INIT[] = "Display init";
|
static const char EN_DISPLAY_INIT[] = "Display init";
|
||||||
static const char EN_WIFI_INIT[] = "WiFi init";
|
static const char EN_WIFI_INIT[] = "WiFi init";
|
||||||
static const char EN_WEBSERVER_INIT[] = "Webserver init";
|
static const char EN_WEBSERVER_INIT[] = "Webserver init";
|
||||||
|
static const char EN_API_INIT[] = "API init";
|
||||||
static const char EN_NFC_INIT[] = "NFC init";
|
static const char EN_NFC_INIT[] = "NFC init";
|
||||||
static const char EN_SEARCHING_SCALE[] = "Searching scale";
|
static const char EN_SEARCHING_SCALE[] = "Searching scale";
|
||||||
|
static const char EN_INIT_DONE[] = "Setup finished";
|
||||||
|
|
||||||
static const char EN_TARE_SCALE[] = "TARE Scale";
|
static const char EN_TARE_SCALE[] = "TARE Scale";
|
||||||
static const char EN_SCALE_NOT_CAL[] = "Scale not calibrated";
|
static const char EN_SCALE_NOT_CAL[] = "Scale not calibrated";
|
||||||
@@ -76,14 +78,19 @@ static const char EN_WIFI_RECONN[] = "WiFi reconnecting";
|
|||||||
static const char EN_UPDATE[] = "Update";
|
static const char EN_UPDATE[] = "Update";
|
||||||
static const char EN_DOWNLOAD[] = "Download";
|
static const char EN_DOWNLOAD[] = "Download";
|
||||||
|
|
||||||
|
static const char EN_NOSCALE_MODE[] = "Activate NFC-only mode";
|
||||||
|
static const char EN_NOSCALE_PROMPT[] = "ready...";
|
||||||
|
|
||||||
// =====================================================================
|
// =====================================================================
|
||||||
// German strings
|
// German strings
|
||||||
// =====================================================================
|
// =====================================================================
|
||||||
static const char DE_DISPLAY_INIT[] = "Display init";
|
static const char DE_DISPLAY_INIT[] = "Display init";
|
||||||
static const char DE_WIFI_INIT[] = "WiFi init";
|
static const char DE_WIFI_INIT[] = "WiFi init";
|
||||||
static const char DE_WEBSERVER_INIT[] = "Webserver init";
|
static const char DE_WEBSERVER_INIT[] = "Webserver init";
|
||||||
|
static const char DE_API_INIT[] = "API init";
|
||||||
static const char DE_NFC_INIT[] = "NFC init";
|
static const char DE_NFC_INIT[] = "NFC init";
|
||||||
static const char DE_SEARCHING_SCALE[] = "Suche Waage";
|
static const char DE_SEARCHING_SCALE[] = "Suche Waage";
|
||||||
|
static const char DE_INIT_DONE[] = "Setup abgeschlossen";
|
||||||
|
|
||||||
static const char DE_TARE_SCALE[] = "Waage tarieren";
|
static const char DE_TARE_SCALE[] = "Waage tarieren";
|
||||||
static const char DE_SCALE_NOT_CAL[] = "Waage nicht kalibriert";
|
static const char DE_SCALE_NOT_CAL[] = "Waage nicht kalibriert";
|
||||||
@@ -148,6 +155,9 @@ static const char DE_WIFI_RECONN[] = "WiFi Neuverbindung";
|
|||||||
static const char DE_UPDATE[] = "Update";
|
static const char DE_UPDATE[] = "Update";
|
||||||
static const char DE_DOWNLOAD[] = "Download";
|
static const char DE_DOWNLOAD[] = "Download";
|
||||||
|
|
||||||
|
static const char DE_NOSCALE_MODE[] = "Aktiviere NFC-only Modus";
|
||||||
|
static const char DE_NOSCALE_PROMPT[] = "bereit...";
|
||||||
|
|
||||||
// =====================================================================
|
// =====================================================================
|
||||||
// String table: [StringID][Lang]
|
// String table: [StringID][Lang]
|
||||||
// =====================================================================
|
// =====================================================================
|
||||||
@@ -156,8 +166,10 @@ static const char* const stringTable[STR_COUNT][LANG_COUNT] = {
|
|||||||
{ EN_DISPLAY_INIT, DE_DISPLAY_INIT },
|
{ EN_DISPLAY_INIT, DE_DISPLAY_INIT },
|
||||||
{ EN_WIFI_INIT, DE_WIFI_INIT },
|
{ EN_WIFI_INIT, DE_WIFI_INIT },
|
||||||
{ EN_WEBSERVER_INIT, DE_WEBSERVER_INIT },
|
{ EN_WEBSERVER_INIT, DE_WEBSERVER_INIT },
|
||||||
|
{ EN_API_INIT, DE_API_INIT },
|
||||||
{ EN_NFC_INIT, DE_NFC_INIT },
|
{ EN_NFC_INIT, DE_NFC_INIT },
|
||||||
{ EN_SEARCHING_SCALE, DE_SEARCHING_SCALE },
|
{ EN_SEARCHING_SCALE, DE_SEARCHING_SCALE },
|
||||||
|
{ EN_INIT_DONE, DE_INIT_DONE },
|
||||||
|
|
||||||
// Scale
|
// Scale
|
||||||
{ EN_TARE_SCALE, DE_TARE_SCALE },
|
{ EN_TARE_SCALE, DE_TARE_SCALE },
|
||||||
@@ -227,6 +239,10 @@ static const char* const stringTable[STR_COUNT][LANG_COUNT] = {
|
|||||||
// OTA
|
// OTA
|
||||||
{ EN_UPDATE, DE_UPDATE },
|
{ EN_UPDATE, DE_UPDATE },
|
||||||
{ EN_DOWNLOAD, DE_DOWNLOAD },
|
{ EN_DOWNLOAD, DE_DOWNLOAD },
|
||||||
|
|
||||||
|
// No-Scale mode
|
||||||
|
{ EN_NOSCALE_MODE, DE_NOSCALE_MODE },
|
||||||
|
{ EN_NOSCALE_PROMPT, DE_NOSCALE_PROMPT },
|
||||||
};
|
};
|
||||||
|
|
||||||
const char* tr(StringID id) {
|
const char* tr(StringID id) {
|
||||||
|
|||||||
@@ -16,8 +16,10 @@ enum StringID : uint8_t {
|
|||||||
STR_DISPLAY_INIT,
|
STR_DISPLAY_INIT,
|
||||||
STR_WIFI_INIT,
|
STR_WIFI_INIT,
|
||||||
STR_WEBSERVER_INIT,
|
STR_WEBSERVER_INIT,
|
||||||
|
STR_API_INIT,
|
||||||
STR_NFC_INIT,
|
STR_NFC_INIT,
|
||||||
STR_SEARCHING_SCALE,
|
STR_SEARCHING_SCALE,
|
||||||
|
STR_INIT_DONE,
|
||||||
|
|
||||||
// Scale
|
// Scale
|
||||||
STR_TARE_SCALE,
|
STR_TARE_SCALE,
|
||||||
@@ -88,6 +90,10 @@ enum StringID : uint8_t {
|
|||||||
STR_UPDATE,
|
STR_UPDATE,
|
||||||
STR_DOWNLOAD,
|
STR_DOWNLOAD,
|
||||||
|
|
||||||
|
// No-Scale mode
|
||||||
|
STR_NOSCALE_MODE,
|
||||||
|
STR_NOSCALE_PROMPT,
|
||||||
|
|
||||||
STR_COUNT // must be last
|
STR_COUNT // must be last
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+18
-5
@@ -61,15 +61,24 @@ void setup() {
|
|||||||
|
|
||||||
// Scale
|
// Scale
|
||||||
start_scale(touchSensorConnected);
|
start_scale(touchSensorConnected);
|
||||||
scaleTareRequest = true;
|
if (scaleConnected){
|
||||||
|
scaleTareRequest = true;
|
||||||
|
}
|
||||||
|
|
||||||
// WDT initialisieren mit 10 Sekunden Timeout
|
// WDT initialisieren mit 10 Sekunden Timeout
|
||||||
bool panic = true; // Wenn true, löst ein WDT-Timeout einen System-Panik aus
|
bool panic = true; // Wenn true, löst ein WDT-Timeout einen System-Panik aus
|
||||||
esp_task_wdt_init(10, panic);
|
esp_task_wdt_init(10, panic);
|
||||||
|
|
||||||
booting = false;
|
booting = false;
|
||||||
|
oledShowProgressBar(6, NUM_SETUP_STEPS, DISPLAY_BOOT_TEXT, tr(STR_INIT_DONE));
|
||||||
|
|
||||||
// Aktuellen Task (loopTask) zum Watchdog hinzufügen
|
// Aktuellen Task (loopTask) zum Watchdog hinzufügen
|
||||||
esp_task_wdt_add(NULL);
|
esp_task_wdt_add(NULL);
|
||||||
|
|
||||||
|
if ( !scaleConnected ) {
|
||||||
|
// Clear Display after Boot
|
||||||
|
oledDisplayText(tr(STR_NOSCALE_PROMPT));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -119,11 +128,14 @@ void loop() {
|
|||||||
oledShowConnectionError(tr(STR_API_CONN_LOST), WiFi.localIP().toString());
|
oledShowConnectionError(tr(STR_API_CONN_LOST), WiFi.localIP().toString());
|
||||||
oledSetPriority(DISPLAY_PRIORITY_WARNING, 3000);
|
oledSetPriority(DISPLAY_PRIORITY_WARNING, 3000);
|
||||||
mainTaskWasPaused = true;
|
mainTaskWasPaused = true;
|
||||||
|
} else if ( !scaleConnected ){
|
||||||
|
// everything fine again: without scale manual clearing of the error msg is needed
|
||||||
|
oledDisplayText(tr(STR_NOSCALE_PROMPT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Überprüfe den Status des Touch Sensors
|
// Überprüfe den Status des Touch Sensors (nur wenn Waage vorhanden)
|
||||||
if (touchSensorConnected && digitalRead(TTP223_PIN) == HIGH && currentMillis - lastButtonPress > debounceDelay)
|
if (scaleConnected && touchSensorConnected && digitalRead(TTP223_PIN) == HIGH && currentMillis - lastButtonPress > debounceDelay)
|
||||||
{
|
{
|
||||||
lastButtonPress = currentMillis;
|
lastButtonPress = currentMillis;
|
||||||
scaleTareRequest = true;
|
scaleTareRequest = true;
|
||||||
@@ -158,7 +170,7 @@ void loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If scale is not calibrated, only show a warning
|
// If scale is not calibrated, only show a warning
|
||||||
if (!scaleCalibrated)
|
if (scaleConnected && !scaleCalibrated)
|
||||||
{
|
{
|
||||||
// Do not show the warning if the calibratin process is onging
|
// Do not show the warning if the calibratin process is onging
|
||||||
if(!scaleCalibrationActive){
|
if(!scaleCalibrationActive){
|
||||||
@@ -166,7 +178,8 @@ void loop() {
|
|||||||
vTaskDelay(pdMS_TO_TICKS(1000));
|
vTaskDelay(pdMS_TO_TICKS(1000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (scaleConnected && scaleCalibrated)
|
||||||
{
|
{
|
||||||
// Ausgabe der Waage auf Display
|
// Ausgabe der Waage auf Display
|
||||||
// Block weight display during NFC write operations and higher-priority display messages
|
// Block weight display during NFC write operations and higher-priority display messages
|
||||||
|
|||||||
+1
-1
@@ -2227,7 +2227,7 @@ void scanRfidTask(void * parameter) {
|
|||||||
|
|
||||||
void startNfc() {
|
void startNfc() {
|
||||||
nfcRequestMutex = xSemaphoreCreateMutex();
|
nfcRequestMutex = xSemaphoreCreateMutex();
|
||||||
oledShowProgressBar(5, 7, DISPLAY_BOOT_TEXT, tr(STR_NFC_INIT));
|
oledShowProgressBar(4, NUM_SETUP_STEPS, DISPLAY_BOOT_TEXT, tr(STR_NFC_INIT));
|
||||||
nfc.begin(); // Beginne Kommunikation mit RFID Leser
|
nfc.begin(); // Beginne Kommunikation mit RFID Leser
|
||||||
|
|
||||||
delay(1000);
|
delay(1000);
|
||||||
|
|||||||
+144
-33
@@ -35,10 +35,22 @@ uint8_t scale_tare_counter = 0;
|
|||||||
bool scaleTareRequest = false;
|
bool scaleTareRequest = false;
|
||||||
uint8_t pauseMainTask = 0;
|
uint8_t pauseMainTask = 0;
|
||||||
bool scaleCalibrated;
|
bool scaleCalibrated;
|
||||||
|
bool scaleConnected;
|
||||||
bool autoTare = true;
|
bool autoTare = true;
|
||||||
bool scaleCalibrationActive = false;
|
bool scaleCalibrationActive = false;
|
||||||
volatile bool scaleCalibrationRequest = false;
|
volatile bool scaleCalibrationRequest = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Non blocking wait function
|
||||||
|
*/
|
||||||
|
void friendlyWait(uint16_t ticks) {
|
||||||
|
for (uint16_t i = 0; i < ticks; i++) {
|
||||||
|
yield();
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(1));
|
||||||
|
esp_task_wdt_reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ##### Weight stabilization functions #####
|
// ##### Weight stabilization functions #####
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -224,6 +236,102 @@ void scale_loop(void * parameter) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long readHX711Raw() {
|
||||||
|
long value = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < 24; i++) {
|
||||||
|
digitalWrite(LOADCELL_SCK_PIN, HIGH);
|
||||||
|
delayMicroseconds(1);
|
||||||
|
|
||||||
|
value = (value << 1) | digitalRead(LOADCELL_DOUT_PIN);
|
||||||
|
|
||||||
|
digitalWrite(LOADCELL_SCK_PIN, LOW);
|
||||||
|
delayMicroseconds(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gain = 128 (1 extra pulse)
|
||||||
|
digitalWrite(LOADCELL_SCK_PIN, HIGH);
|
||||||
|
delayMicroseconds(1);
|
||||||
|
digitalWrite(LOADCELL_SCK_PIN, LOW);
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool deepSearchScale() {
|
||||||
|
// without pull-up resistor (10k) on LOADCELL_DOUT_PIN the hx711 lib functions
|
||||||
|
// are not reliable in detecting a missing chip
|
||||||
|
// these tests work even without pull-up resistor
|
||||||
|
const uint32_t timeout = 1000;
|
||||||
|
const int samples = 10;
|
||||||
|
|
||||||
|
pinMode(LOADCELL_DOUT_PIN, INPUT);
|
||||||
|
pinMode(LOADCELL_SCK_PIN, OUTPUT);
|
||||||
|
digitalWrite(LOADCELL_SCK_PIN, LOW);
|
||||||
|
|
||||||
|
//delay(500);
|
||||||
|
friendlyWait(500);
|
||||||
|
|
||||||
|
// 1. HX711 vorhanden?
|
||||||
|
uint32_t start = millis();
|
||||||
|
while (digitalRead(LOADCELL_DOUT_PIN) == HIGH) {
|
||||||
|
if (millis() - start > timeout) {
|
||||||
|
Serial.println("HX711 not found (DOUT stays HIGH).");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Serial.println("HX711 seems to answer...");
|
||||||
|
|
||||||
|
// 2. Mehrere Werte lesen
|
||||||
|
long values[samples];
|
||||||
|
|
||||||
|
for (int i = 0; i < samples; i++) {
|
||||||
|
// warten bis bereit
|
||||||
|
uint32_t t = millis();
|
||||||
|
while (digitalRead(LOADCELL_DOUT_PIN) == HIGH) {
|
||||||
|
if (millis() - t > timeout) {
|
||||||
|
Serial.println("HX711 not found (Timeout during read).");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
values[i] = readHX711Raw();
|
||||||
|
delay(50);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Analyse
|
||||||
|
int invalidCount = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < samples; i++) {
|
||||||
|
if (values[i] == 0 || values[i] == 0xFFFFFF) {
|
||||||
|
invalidCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. Entscheidungen
|
||||||
|
|
||||||
|
// Kein Sensor
|
||||||
|
if (invalidCount > samples / 2) {
|
||||||
|
Serial.println("HX711 not ready (Loadcell missing).");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Serial.println("HX711 found.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool scaleDetected(){
|
||||||
|
// Step 1: use hx711 library functions (need pull-up resistor to recognize missing hx711)
|
||||||
|
if ( !(scale.wait_ready_timeout(1000))) {
|
||||||
|
Serial.println("HX711 not found (pull-up resistor installed).");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Step 2: when pull-up resistor is missing, then deep search...
|
||||||
|
return deepSearchScale();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void start_scale(bool touchSensorConnected) {
|
void start_scale(bool touchSensorConnected) {
|
||||||
Serial.println("Prüfe Calibration Value");
|
Serial.println("Prüfe Calibration Value");
|
||||||
float calibrationValue;
|
float calibrationValue;
|
||||||
@@ -252,40 +360,43 @@ void start_scale(bool touchSensorConnected) {
|
|||||||
|
|
||||||
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
|
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
|
||||||
|
|
||||||
oledShowProgressBar(6, 7, DISPLAY_BOOT_TEXT, tr(STR_SEARCHING_SCALE));
|
oledShowProgressBar(5, NUM_SETUP_STEPS, DISPLAY_BOOT_TEXT, tr(STR_SEARCHING_SCALE));
|
||||||
for (uint16_t i = 0; i < 3000; i++) {
|
friendlyWait(3000);
|
||||||
yield();
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(1));
|
scaleConnected = scaleDetected();
|
||||||
esp_task_wdt_reset();
|
if ( scaleConnected ) {
|
||||||
|
scale.set_scale(calibrationValue);
|
||||||
|
//vTaskDelay(pdMS_TO_TICKS(5000));
|
||||||
|
|
||||||
|
// Initialize weight stabilization filter
|
||||||
|
resetWeightFilter();
|
||||||
|
|
||||||
|
// Display Gewicht
|
||||||
|
oledShowWeight(0);
|
||||||
|
|
||||||
|
Serial.println("starte Scale Task");
|
||||||
|
BaseType_t result = xTaskCreatePinnedToCore(
|
||||||
|
scale_loop, /* Function to implement the task */
|
||||||
|
"ScaleLoop", /* Name of the task */
|
||||||
|
2048, /* Stack size in words */
|
||||||
|
NULL, /* Task input parameter */
|
||||||
|
scaleTaskPrio, /* Priority of the task */
|
||||||
|
&ScaleTask, /* Task handle. */
|
||||||
|
scaleTaskCore); /* Core where the task should run */
|
||||||
|
|
||||||
|
if (result != pdPASS) {
|
||||||
|
Serial.println("Fehler beim Erstellen des ScaleLoop-Tasks");
|
||||||
|
} else {
|
||||||
|
Serial.println("ScaleLoop-Task erfolgreich erstellt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
while(!scale.is_ready()) {
|
// No HX711 - switching to NFC-only mode
|
||||||
vTaskDelay(pdMS_TO_TICKS(5000));
|
Serial.println("Kann kein HX711 Board finden !"); // Sende Text "Kann kein..." an seriellen Monitor
|
||||||
}
|
oledDisplayText(tr(STR_HX711_NOT_FOUND));
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(1500));
|
||||||
scale.set_scale(calibrationValue);
|
oledDisplayText(tr(STR_NOSCALE_MODE));
|
||||||
//vTaskDelay(pdMS_TO_TICKS(5000));
|
vTaskDelay(pdMS_TO_TICKS(1500));
|
||||||
|
|
||||||
// Initialize weight stabilization filter
|
|
||||||
resetWeightFilter();
|
|
||||||
|
|
||||||
// Display Gewicht
|
|
||||||
oledShowWeight(0);
|
|
||||||
|
|
||||||
Serial.println("starte Scale Task");
|
|
||||||
BaseType_t result = xTaskCreatePinnedToCore(
|
|
||||||
scale_loop, /* Function to implement the task */
|
|
||||||
"ScaleLoop", /* Name of the task */
|
|
||||||
2048, /* Stack size in words */
|
|
||||||
NULL, /* Task input parameter */
|
|
||||||
scaleTaskPrio, /* Priority of the task */
|
|
||||||
&ScaleTask, /* Task handle. */
|
|
||||||
scaleTaskCore); /* Core where the task should run */
|
|
||||||
|
|
||||||
if (result != pdPASS) {
|
|
||||||
Serial.println("Fehler beim Erstellen des ScaleLoop-Tasks");
|
|
||||||
} else {
|
|
||||||
Serial.println("ScaleLoop-Task erfolgreich erstellt");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ extern uint8_t scale_tare_counter;
|
|||||||
extern bool scaleTareRequest;
|
extern bool scaleTareRequest;
|
||||||
extern uint8_t pauseMainTask;
|
extern uint8_t pauseMainTask;
|
||||||
extern bool scaleCalibrated;
|
extern bool scaleCalibrated;
|
||||||
|
extern bool scaleConnected;
|
||||||
extern bool autoTare;
|
extern bool autoTare;
|
||||||
extern bool scaleCalibrationActive;
|
extern bool scaleCalibrationActive;
|
||||||
extern volatile bool scaleCalibrationRequest;
|
extern volatile bool scaleCalibrationRequest;
|
||||||
|
|||||||
+1
-1
@@ -124,7 +124,7 @@ void sendNfcData() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setupWebserver(AsyncWebServer &server) {
|
void setupWebserver(AsyncWebServer &server) {
|
||||||
oledShowProgressBar(2, 7, DISPLAY_BOOT_TEXT, tr(STR_WEBSERVER_INIT));
|
oledShowProgressBar(2, NUM_SETUP_STEPS, DISPLAY_BOOT_TEXT, tr(STR_WEBSERVER_INIT));
|
||||||
|
|
||||||
ws.onEvent(onWsEvent);
|
ws.onEvent(onWsEvent);
|
||||||
server.addHandler(&ws);
|
server.addHandler(&ws);
|
||||||
|
|||||||
+1
-1
@@ -51,7 +51,7 @@ void initWiFi() {
|
|||||||
wm.setWiFiAutoReconnect(true);
|
wm.setWiFiAutoReconnect(true);
|
||||||
wm.setConnectTimeout(10);
|
wm.setConnectTimeout(10);
|
||||||
|
|
||||||
oledShowProgressBar(1, 7, DISPLAY_BOOT_TEXT, tr(STR_WIFI_INIT));
|
oledShowProgressBar(1, NUM_SETUP_STEPS, DISPLAY_BOOT_TEXT, tr(STR_WIFI_INIT));
|
||||||
|
|
||||||
//bool res = wm.autoConnect("FilaMan"); // anonymous ap
|
//bool res = wm.autoConnect("FilaMan"); // anonymous ap
|
||||||
if(!wm.autoConnect("FilaMan")) {
|
if(!wm.autoConnect("FilaMan")) {
|
||||||
|
|||||||
Reference in new issue
Block a user