Skip to content

Commit

Permalink
Remove local (on the board) callback hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
vickash committed Aug 10, 2024
1 parent b90361a commit 0bc7b8c
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 52 deletions.
14 changes: 0 additions & 14 deletions src/denko_ethernet.ino
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ void setup() {
Ethernet.begin(mac, ip);
server.begin();
printEthernetStatus();

// Add listener callbacks for local logic.
denko.digitalListenCallback = onDigitalListen;
denko.analogListenCallback = onAnalogListen;
}

void loop() {
Expand All @@ -58,13 +54,3 @@ void loop() {
// Main loop of the denko library.
denko.run();
}

// This runs every time a digital pin that denko is listening to changes value.
// p = pin number, v = current value
void onDigitalListen(byte p, byte v){
}

// This runs every time an analog pin that denko is listening to gets read.
// p = pin number, v = read value
void onAnalogListen(byte p, int v){
}
14 changes: 0 additions & 14 deletions src/denko_serial.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,8 @@ void setup() {

// Pass serial stream to denko so it can read/write.
denko.stream = &DENKO_SERIAL_IF;

// Add listener callbacks for local logic.
denko.digitalListenCallback = onDigitalListen;
denko.analogListenCallback = onAnalogListen;
}

void loop() {
denko.run();
}

// This runs every time a digital pin that denko is listening to changes value.
// p = pin number, v = current value
void onDigitalListen(byte p, byte v){
}

// This runs every time an analog pin that denko is listening to gets read.
// p = pin number, v = read value
void onAnalogListen(byte p, int v){
}
14 changes: 0 additions & 14 deletions src/denko_wifi.ino
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,6 @@ void setup() {
// Start the denko TCP server.
server.begin();

// Add listener callbacks for local logic.
denko.digitalListenCallback = onDigitalListen;
denko.analogListenCallback = onAnalogListen;

// Use DENKO_SERIAL_IF as the denko IO stream until we get a TCP connection.
denko.stream = &DENKO_SERIAL_IF;
}
Expand Down Expand Up @@ -190,13 +186,3 @@ void loop() {
// Main loop of the denko library.
denko.run();
}

// This runs every time a digital pin that denko is listening to changes value.
// p = pin number, v = current value
void onDigitalListen(byte p, byte v){
}

// This runs every time an analog pin that denko is listening to gets read.
// p = pin number, v = read value
void onAnalogListen(byte p, int v){
}
8 changes: 0 additions & 8 deletions src/lib/Denko.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ class Denko {
// Store it and call ->print, ->write, ->available, ->read etc. on it.
Stream* stream;

// Callback hooks for local logic (defined in main sketch) based on listeners.
// These should be used if:
// 1) a round-trip to the remote client is too slow, or
// 2) something needs to happen regardless of remote client connection.
// Eg. Instant feedback from a smart light switch.
void (*digitalListenCallback)(byte p, byte v);
void (*analogListenCallback)(byte p, int v);

// Core IO API Functions
// Functions with a cmd value can be called through the remote API.
//
Expand Down
2 changes: 0 additions & 2 deletions src/lib/DenkoCoreIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ void Denko::updateCoreListeners() {
// Handle a single analog listener when it needs to read.
void Denko::analogListenerUpdate(byte i){
int rval = analogRead(listeners[i][1]);
analogListenCallback(listeners[i][1], rval);
coreResponse(listeners[i][1], rval);
}

Expand All @@ -294,7 +293,6 @@ void Denko::digitalListenerUpdate(byte i){
if (rval != bitRead(listeners[i][0], 5)){
// State for digital listeners is stored in byte 5 of the listener itself.
bitWrite(listeners[i][0], 5, rval);
digitalListenCallback(listeners[i][1], rval);
coreResponse(listeners[i][1], rval);
}
}
Expand Down

0 comments on commit 0bc7b8c

Please sign in to comment.