climate display implementation
This commit is contained in:
parent
2d0d38ecf3
commit
ea2c2e076b
14 changed files with 213 additions and 342 deletions
|
@ -1,22 +0,0 @@
|
|||
#include <ESPMegaPRO.h>
|
||||
#define ADC
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
ESPMega_begin();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
#ifdef DAC
|
||||
for(int i=0;i<4096;i++) {
|
||||
ESPMega_dacWrite(0,i);
|
||||
double dac_val_sine = 2047.5*sin(i*2*PI/2047.5)+2047.5;
|
||||
ESPMega_dacWrite(1,(int)dac_val_sine);
|
||||
}
|
||||
#endif
|
||||
#ifdef ADC
|
||||
Serial.printf("A0: %d",ESPMega_analogRead(0));
|
||||
#endif
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
#include <ESPMegaPRO_OOP.hpp>
|
||||
#include <DigitalInputCard.hpp>
|
||||
#include <DigitalOutputCard.hpp>
|
||||
#include <AnalogCard.hpp>
|
||||
|
||||
// This code demonstrates how to use the cards
|
||||
|
||||
ESPMegaPRO espmega = ESPMegaPRO();
|
||||
AnalogCard analogCard = AnalogCard();
|
||||
|
||||
void inputCallback(uint8_t pin, bool state)
|
||||
{
|
||||
Serial.print("Input ");
|
||||
Serial.print(pin);
|
||||
Serial.print(" changed to ");
|
||||
Serial.println(state);
|
||||
}
|
||||
|
||||
void printInputs()
|
||||
{
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
Serial.print("Input ");
|
||||
Serial.print(i);
|
||||
Serial.print(": ");
|
||||
Serial.print(espmega.inputs.digitalRead(i));
|
||||
Serial.println();
|
||||
}
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Instantiate ESPMega
|
||||
espmega.begin();
|
||||
Serial.println("ESPMega initialized");
|
||||
// Read all the inputs and print them
|
||||
printInputs();
|
||||
// Turn on all the outputs
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
espmega.outputs.digitalWrite(i, true);
|
||||
}
|
||||
// Set the debounce time for all inputs to 200ms
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
espmega.inputs.setDebounceTime(i, 200);
|
||||
}
|
||||
// Register the callback function
|
||||
espmega.inputs.registerCallback(inputCallback);
|
||||
|
||||
// Install the analog card
|
||||
Serial.println("Installing analog card");
|
||||
if (espmega.installCard(0, &analogCard))
|
||||
{
|
||||
Serial.println("Analog card installed");
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("Failed to install analog card");
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long previousMillis = 0;
|
||||
const unsigned long interval = 1000; // 1 second
|
||||
|
||||
void loop()
|
||||
{
|
||||
unsigned long currentMillis = millis();
|
||||
|
||||
if (currentMillis - previousMillis >= interval)
|
||||
{
|
||||
previousMillis = currentMillis;
|
||||
printInputs();
|
||||
}
|
||||
espmega.loop();
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
#include <ESPMegaPRO.h>
|
||||
void setup()
|
||||
{
|
||||
ESPMega_begin();
|
||||
Serial.begin(115200);
|
||||
uint8_t a = 35;
|
||||
uint8_t b = 42;
|
||||
uint8_t c = 66;
|
||||
uint8_t d = 251;
|
||||
|
||||
// ESPMega_FRAM.write8(0,a);
|
||||
// ESPMega_FRAM.write8(1,b);
|
||||
// ESPMega_FRAM.write8(2,c);
|
||||
// ESPMega_FRAM.write8(3,d);
|
||||
|
||||
uint8_t e = ESPMega_FRAM.read8(0);
|
||||
uint8_t f = ESPMega_FRAM.read8(1);
|
||||
uint8_t g = ESPMega_FRAM.read8(2);
|
||||
uint8_t h = ESPMega_FRAM.read8(3);
|
||||
Serial.println(e);
|
||||
Serial.println(f);
|
||||
Serial.println(g);
|
||||
Serial.println(h);
|
||||
char ll[2000] = "Everyone has a dream they strive to achieve, and so does the musically talented Kanon Shibuya. However, due to her stage fright, Kanon fails to make it into Yuigaoka Girls' High School's music program and instead ends up in the general curriculum. Even though Kanon makes the conscious decision to quit music altogether, her classmate Tang Keke rekindles Kanon's passion for music with her own: a passion for school idols.";
|
||||
|
||||
// ESPMega_FRAM.write(4,(uint8_t*)ll,2000);
|
||||
|
||||
char llr[2000];
|
||||
ESPMega_FRAM.read(4,(uint8_t*)llr,2000);
|
||||
Serial.println(llr);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
#include <Arduino.h>
|
||||
#include <PCF8574.h>
|
||||
|
||||
PCF8574 inputbank1(0x21);
|
||||
|
||||
void setup() {
|
||||
Wire.begin(14,33);
|
||||
Serial.begin(9600);
|
||||
boolean connected = inputbank1.begin();
|
||||
Serial.println("connection state = "+String(connected));
|
||||
inputbank1.write(0, HIGH);
|
||||
delay(50);
|
||||
inputbank1.write(1, HIGH);
|
||||
delay(50);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
for(int i=2;i<8;i++) {
|
||||
Serial.println(inputbank1.read(i));
|
||||
delay(100);
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
#include "ESPMegaPRO.h"
|
||||
|
||||
void setup() {
|
||||
ESPMega_begin();
|
||||
Serial.begin(115200);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if(ESPMega_digitalRead(11)) {
|
||||
ESPMega_digitalWrite(8, HIGH);
|
||||
Serial.println("11HIGH");
|
||||
} else {
|
||||
ESPMega_digitalWrite(8, LOW);
|
||||
Serial.println("11LOW");
|
||||
}
|
||||
ESPMega_loop();
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
#include <ESPMegaPRO_OOP.hpp>
|
||||
#include <ETH.h>
|
||||
// Instantiate ESPMega
|
||||
ESPMegaPRO espmega = ESPMegaPRO();
|
||||
|
||||
void mqtt_callback(char *topic, char *payload)
|
||||
{
|
||||
Serial.print("MQTT Callback: ");
|
||||
Serial.print(topic);
|
||||
Serial.print(" ");
|
||||
Serial.println(payload);
|
||||
}
|
||||
|
||||
IPAddress ip(192, 168, 0, 11);
|
||||
IPAddress gateway(192, 168, 0, 1);
|
||||
IPAddress subnet(255, 255, 255, 0);
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Initialize ESPMega
|
||||
espmega.begin();
|
||||
espmega.enableIotModule();
|
||||
ETH.begin();
|
||||
ETH.config(ip, gateway, subnet);
|
||||
espmega.iot.setBaseTopic("/testmegaoop");
|
||||
espmega.iot.connectToMqtt("espmega", "192.168.0.26", 1883);
|
||||
espmega.iot.publishRelative("test", "test");
|
||||
espmega.iot.subscribeRelative("test");
|
||||
espmega.iot.registerMqttCallback(mqtt_callback);
|
||||
espmega.iot.registerCard(1);
|
||||
espmega.iot.publishCard(1);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Call ESPMega loop
|
||||
espmega.loop();
|
||||
}
|
|
@ -8,6 +8,25 @@
|
|||
// Demo PLC firmware using the ESPMegaPRO OOP library
|
||||
|
||||
ESPMegaPRO espmega = ESPMegaPRO();
|
||||
const uint16_t irCode[15][4][4][1] = {0};
|
||||
const char* mode_names[] = {"Off", "Fan-only", "Cool"};
|
||||
const char* fan_speed_names[] = {"Auto", "Low", "Medium", "High"};
|
||||
|
||||
size_t getInfraredCode(uint8_t mode, uint8_t fan_speed, uint8_t temperature, const uint16_t** codePtr) {
|
||||
// Change the code pointer to point to the IR timing array
|
||||
*codePtr = &(irCode[mode][fan_speed][temperature][0]);
|
||||
return sizeof(irCode[mode][fan_speed][temperature]) / sizeof(uint16_t);
|
||||
}
|
||||
AirConditioner ac = {
|
||||
.max_temperature = 30,
|
||||
.min_temperature = 16,
|
||||
.modes = 4,
|
||||
.mode_names = mode_names,
|
||||
.fan_speeds = 4,
|
||||
.fan_speed_names = fan_speed_names,
|
||||
.getInfraredCode = &getInfraredCode
|
||||
};
|
||||
ClimateCard climateCard = ClimateCard(14, ac);
|
||||
|
||||
void input_change_callback(uint8_t pin, uint8_t value) {
|
||||
Serial.print("Input change callback: ");
|
||||
|
@ -68,8 +87,11 @@ void setup() {
|
|||
espmega.iot->registerCard(1);
|
||||
Serial.println("Registering Input Change Callback");
|
||||
espmega.inputs.registerCallback(input_change_callback);
|
||||
Serial.println("Installing Climate Card");
|
||||
espmega.installCard(2, &climateCard);
|
||||
Serial.println("Enabling Internal Display");
|
||||
espmega.enableInternalDisplay(&Serial);
|
||||
espmega.display->bindClimateCard(&climateCard);
|
||||
Serial.println("Initialization Routine Complete");
|
||||
}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
#include <ESPMegaPRO.h>
|
||||
|
||||
void lcd_send_stop_bit();
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
lcd_send_stop_bit();
|
||||
Serial.print("rest");
|
||||
lcd_send_stop_bit();
|
||||
Serial.print("connect");
|
||||
lcd_send_stop_bit();
|
||||
delay(1000);
|
||||
Serial.print("whmi-wri 1024,115200,res0");
|
||||
lcd_send_stop_bit();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
while(Serial.available()) {
|
||||
Serial.write(Serial.read());
|
||||
}
|
||||
}
|
||||
|
||||
void lcd_send_stop_bit() {
|
||||
Serial.write(0xFF);
|
||||
Serial.write(0xFF);
|
||||
Serial.write(0xFF);
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
#include <Arduino.h>
|
||||
#include "Wire.h"
|
||||
#include <Adafruit_PWMServoDriver.h>
|
||||
|
||||
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x5F);
|
||||
|
||||
void setup() {
|
||||
Wire.begin(14,33);
|
||||
pwm.begin();
|
||||
pwm.setPin(2, 500);
|
||||
pwm.setPin(3, 1000);
|
||||
pwm.setPin(4, 1500);
|
||||
pwm.setPin(5, 2000);
|
||||
pwm.setPin(6, 2500);
|
||||
pwm.setPin(7, 3000);
|
||||
pwm.setPin(8, 3500);
|
||||
pwm.setPin(9, 4000);
|
||||
pwm.setPin(10, 500);
|
||||
pwm.setPin(11, 1000);
|
||||
pwm.setPin(12, 1500);
|
||||
pwm.setPin(13, 2000);
|
||||
pwm.setPin(14, 2500);
|
||||
pwm.setPin(15, 3000);
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
#include <ESPMegaPRO.h>
|
||||
#include <ETH.h>
|
||||
|
||||
uint8_t utc_offset = 7;
|
||||
|
||||
IPAddress IP(192, 168, 0, 241);
|
||||
IPAddress SUBNET(255, 255, 255, 0);
|
||||
IPAddress GATEWAY(192, 168, 0, 1);
|
||||
IPAddress DNS(10, 192, 1, 1);
|
||||
|
||||
void setup()
|
||||
{
|
||||
ESPMega_begin();
|
||||
Serial.begin(115200);
|
||||
ETH.begin();
|
||||
ETH.config(IP, GATEWAY, SUBNET, DNS, DNS);
|
||||
delay(5000);
|
||||
char ntp[19];
|
||||
DNS.toString().toCharArray(ntp, 19);
|
||||
ESPMega_configNTP(utc_offset * 3600, 0, ntp);
|
||||
ESPMega_updateTimeFromNTP();
|
||||
//ESPMega_setTime(0,10,52,9,11,2008);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
rtctime_t time = ESPMega_getTime();
|
||||
Serial.printf("RTC: %02d:%02d:%02d %02d/%02d/%04d\n", time.hours, time.minutes, time.seconds, time.day, time.month, time.year);
|
||||
delay(1000);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue