|
|
@@ -1,4 +1,5 @@
|
|
|
#define HAS_u8g2
|
|
|
+//#define HAS_PCF8591
|
|
|
|
|
|
|
|
|
#include <Arduino.h>
|
|
|
@@ -6,6 +7,9 @@
|
|
|
#include <SPI.h>
|
|
|
#include <Wire.h>
|
|
|
|
|
|
+#include "PCF8591_init.h"
|
|
|
+
|
|
|
+
|
|
|
//SSD1306
|
|
|
#include <Adafruit_SSD1306.h>
|
|
|
#include <Adafruit_GFX.h>
|
|
|
@@ -53,6 +57,7 @@ int test_pwm_pin = 9;
|
|
|
|
|
|
void setup(void) {
|
|
|
Serial.begin (115200);
|
|
|
+ #include "PCF8591_setup.h"
|
|
|
|
|
|
#if defined(HAS_Adafruit_SSD1306)
|
|
|
//SSD1306
|
|
|
@@ -77,6 +82,7 @@ int test_pwm_pin = 9;
|
|
|
pinMode(in_test_status_p5_temp_3, INPUT_PULLUP);
|
|
|
pinMode(in_test_status_p5_temp_4, INPUT_PULLUP);
|
|
|
|
|
|
+ pinMode(in_test_status_p5_current, INPUT_PULLUP);
|
|
|
|
|
|
|
|
|
|
|
|
@@ -92,49 +98,58 @@ int test_pwm_pin = 9;
|
|
|
#include "i2c_scanner_setup.h"
|
|
|
i2c_scanner();
|
|
|
#endif
|
|
|
+
|
|
|
+
|
|
|
+ byte count = 0;
|
|
|
+ pinMode(13,OUTPUT);
|
|
|
+ digitalWrite(13,HIGH);
|
|
|
+ Wire.begin();
|
|
|
+ for (byte i = 1; i < 120; i++)
|
|
|
+ {
|
|
|
+ Wire.beginTransmission (i);
|
|
|
+ if (Wire.endTransmission () == 0)
|
|
|
+ {
|
|
|
+ Serial.print ("Found address: ");
|
|
|
+ Serial.print (i, DEC);
|
|
|
+ Serial.print (" (0x");
|
|
|
+ Serial.print (i, HEX);
|
|
|
+ Serial.println (")");
|
|
|
+ count++;
|
|
|
+ delay (1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Serial.println ("Done.");
|
|
|
+ Serial.print ("Found ");
|
|
|
+ Serial.print (count, DEC);
|
|
|
+ Serial.println (" device(s).");
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//#include "scan_ports.c"
|
|
|
|
|
|
-void status_pin(STATUS_PHYS_PIN_OUTPUT_SYSTEM_CONDITION_T pin) {
|
|
|
- int state = digitalRead(pin );
|
|
|
- if(state == HIGH) {
|
|
|
- // Good
|
|
|
- #if defined(HAS_u8g2)
|
|
|
- // u8g2.setCursor (3, 20);
|
|
|
- u8g2.print (" +");
|
|
|
- u8g2.sendBuffer(); // transfer internal memory to the display
|
|
|
- #endif
|
|
|
- } else {
|
|
|
- // Bad
|
|
|
- #if defined(HAS_u8g2)
|
|
|
- // u8g2.setCursor (3, 20);
|
|
|
- u8g2.print (" -");
|
|
|
- u8g2.sendBuffer(); // transfer internal memory to the display
|
|
|
- #endif
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
void loop(void) {
|
|
|
|
|
|
- /*
|
|
|
-
|
|
|
- delay(2);
|
|
|
- digitalWrite(test_pwm_pin, HIGH);
|
|
|
- delay(2);
|
|
|
- digitalWrite(test_pwm_pin, LOW);
|
|
|
- */
|
|
|
-
|
|
|
- //scan_ports();
|
|
|
- delay(2000);
|
|
|
-
|
|
|
- /*
|
|
|
- int out_test_status_p5_bus_1_port_6_red_led_pin = 5 ;
|
|
|
- int in_test_status_p5_bus_1_port_7_red_buttopn_pin = 6 ;
|
|
|
- int out_test_status_p5_bus_1_port_8_green_led_pin = 7 ;
|
|
|
- int in_test_status_p5_bus_1_port_9_black_buttopn_pin = 8 ;
|
|
|
+
|
|
|
+ delay(STATUS_SYSTEM_LATENCY_MAIN_LOOP_A);
|
|
|
+ /*
|
|
|
+ Serial.print("pcf8591.voltageRead: ");
|
|
|
+ float ana0V = pcf8591.voltageRead(AIN0);
|
|
|
+ Serial.print(ana0V);
|
|
|
+ Serial.print(" , ");
|
|
|
+ float ana1V = pcf8591.voltageRead(AIN1);
|
|
|
+ Serial.print(ana1V);
|
|
|
+ Serial.print(" , ");
|
|
|
+ float ana2V = pcf8591.voltageRead(AIN2);
|
|
|
+ Serial.print(ana2V);
|
|
|
+ Serial.print(" , ");
|
|
|
+ float ana3V = pcf8591.voltageRead(AIN3);
|
|
|
+ Serial.println(ana3V);
|
|
|
+ delay(1000);
|
|
|
*/
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
#if defined(HAS_u8g2)
|
|
|
u8g2.clearBuffer();
|
|
|
u8g2.setFont(u8g2_font_amstrad_cpc_extended_8f); // choose a suitable font
|
|
|
@@ -147,33 +162,39 @@ void loop(void) {
|
|
|
display.display();
|
|
|
#endif
|
|
|
|
|
|
- status_pin(out_test_status_p5_bus_1_port_6_red_led_pin);
|
|
|
+ //status_pin(out_test_status_p5_bus_1_port_6_red_led_pin);
|
|
|
|
|
|
STATUS_PHYS_PIN_INPUT_INT_ERROR_F(STATUS_SYSTEM_CONDITION_A,in_test_status_p5_bus_1_port_7_red_buttopn_pin);
|
|
|
//status_pin(in_test_status_p5_bus_1_port_7_red_buttopn_pin);
|
|
|
|
|
|
- status_pin(out_test_status_p5_bus_1_port_8_green_led_pin);
|
|
|
+ // status_pin(out_test_status_p5_bus_1_port_8_green_led_pin);
|
|
|
STATUS_PHYS_PIN_INPUT_INT_OK_F(STATUS_SYSTEM_CONDITION_A, in_test_status_p5_bus_1_port_9_black_buttopn_pin);
|
|
|
//status_pin(in_test_status_p5_bus_1_port_9_black_buttopn_pin);
|
|
|
- #if defined(HAS_u8g2)
|
|
|
+
|
|
|
+ STATUS_PHYS_PIN_INPUT_RANGE_F(in_test_status_p5_temp_1, in_test_status_p5_temp_1_RANGE_A, STATUS_SYSTEM_CONDITION_ERROR_COUNT_A);
|
|
|
+ STATUS_PHYS_PIN_INPUT_RANGE_F(in_test_status_p5_temp_2, in_test_status_p5_temp_2_RANGE_A, STATUS_SYSTEM_CONDITION_ERROR_COUNT_A);
|
|
|
+ #if defined(HAS_u8g2)
|
|
|
u8g2.setCursor(0,20);
|
|
|
// u8g2.setFont(u8g2_font_m2icon_5_tf); // choose a suitable font
|
|
|
#endif
|
|
|
- STATUS_PHYS_PIN_INPUT_RANGE_F(in_test_status_p5_temp_1, in_test_status_p5_temp_1_RANGE_A, STATUS_SYSTEM_CONDITION_ERROR_COUNT_A);
|
|
|
- STATUS_PHYS_PIN_INPUT_RANGE_F(in_test_status_p5_temp_2, in_test_status_p5_temp_2_RANGE_A, STATUS_SYSTEM_CONDITION_ERROR_COUNT_A);
|
|
|
- #if defined(HAS_u8g2)
|
|
|
- u8g2.setCursor(0,30);
|
|
|
- #endif
|
|
|
+
|
|
|
STATUS_PHYS_PIN_INPUT_RANGE_F(in_test_status_p5_temp_3, in_test_status_p5_temp_3_RANGE_A, STATUS_SYSTEM_CONDITION_ERROR_COUNT_A);
|
|
|
STATUS_PHYS_PIN_INPUT_RANGE_F(in_test_status_p5_temp_4, in_test_status_p5_temp_4_RANGE_A, STATUS_SYSTEM_CONDITION_ERROR_COUNT_A);
|
|
|
+ STATUS_PHYS_PIN_INPUT_RANGE_F(in_test_status_p5_current, in_test_status_p5_curren_RANGE_A, STATUS_SYSTEM_CONDITION_ERROR_COUNT_A);
|
|
|
+
|
|
|
|
|
|
+ #if defined(HAS_u8g2)
|
|
|
+ u8g2.setCursor(0,30);
|
|
|
+ #endif
|
|
|
STATUS_SYSTEM_CONDITION_F(STATUS_SYSTEM_CONDITION_A, STATUS_SYSTEM_CONDITION_ERROR_COUNT_A);
|
|
|
STATUS_PHYS_PIN_OUTPUT_SYSTEM_CONDITION_OK_F(STATUS_SYSTEM_CONDITION_A, out_test_status_p5_bus_1_port_8_green_led_pin );
|
|
|
STATUS_PHYS_PIN_OUTPUT_SYSTEM_CONDITION_ERROR_F(STATUS_SYSTEM_CONDITION_A, out_test_status_p5_bus_1_port_6_red_led_pin );
|
|
|
#if defined(HAS_u8g2)
|
|
|
// u8g2.setCursor(0,40);
|
|
|
//String STATUS_SYSTEM_CONDITION_A_S ;
|
|
|
+ u8g2.print("[");
|
|
|
u8g2.print(String(STATUS_SYSTEM_CONDITION_A, BIN));
|
|
|
+ u8g2.print("]");
|
|
|
u8g2.sendBuffer();
|
|
|
#endif
|
|
|
|