Register / Login | Desktop view |
void setup() {
setupMenu();
Serial.begin(9600);
Wire.begin();
multiIoAddExpander ( multiIo, ioFrom8574(0x20, 2), 10); //Expander pins
ioDevicePinMode(multiIo, EXPANDER1+0, INPUT); //P0 Pin 100 ( P0 auf 8574) Switch
ioDevicePinMode(multiIo, EXPANDER1+1, INPUT_PULLUP); //P1 Pin 101 Encoder Pin A
ioDevicePinMode(multiIo, EXPANDER1+2, INPUT_PULLUP); //P2 Pin 102 Encoder Pin B
ioDevicePinMode(multiIo, EXPANDER1+3, INPUT); //P3 Pin 103 ( P3 auf 8574) Clickwheel Encoder
ioDevicePinMode(multiIo, EXPANDER1+7, OUTPUT); //P7 Pin 107 Test mit LED
switches.initialise(multiIo, true);
switches.addSwitchListener(EXPANDER1 +0, &keyListenerExpander);
switches.addSwitchListener(EXPANDER1 +3, &keyListenerExpander);
//setupRotaryEncoderWithInterrupt(encoderAPin, encoderBPin, onEncoderChange, HWACCEL_REGULAR);
}
#define EXPANDER1 100
MultiIoAbstractionRef multiIo = multiIoExpander(EXPANDER1);
IoAbstractionRef multiIoENC = ioFrom8754(0x20, 2); //2 for Interrupt Pin ESP8266
TcMenu i can only operate if i do not use setupRotaryEncoderWithInterrupt(encoderAPin, encoderBPin, onEncoderChange, HWACCEL_REGULAR);
Using that setup of the Encoder does have as consequence the Encoder does not react in TcMenu.
IoAbstractionRef multiIoENC = ioFrom8754(0x20, 2); i need for TcMenu, without there's no reaction in the Menu, with it does run like a charm.
Being confused a bit as i cannot get an idea how the pins are defined then.
How to setup the Encoder in an multiIoAbstraction for TcMenu
and another Renderer as e.g. using an standard 1366 library ( E.g. Adafruit ) ?
#include "TCMenuTest_dr_menu.h"
#include <TaskManagerIO.h>
#include <IoAbstraction.h>
#include <IoAbstractionWire.h>
#include <wire.h>
#define EXPANDER1 100
MultiIoAbstractionRef multiIo = multiIoExpander(EXPANDER1);
IoAbstractionRef multiIoENC = ioFrom8754(0x20, 2); //2 is Interrupt Pin of ESP8266
#define Button1 100
#define EncoderPinA 101
#define EncoderPinB 102
#define EncoderButton 103
class keyListenerExpander : public SwitchListener {
public:
void onPressed(uint8_t pin, bool held) override {
Serial.println("Pressed " );
}
void onReleased(uint8_t pin, bool held) override {
Serial.println("Released ");
}
private:
} keyListenerExpander;
void onEncoderChange(int newValue)
{
Serial.println("Encoder Change");
}
void setup() {
Serial.begin(9600);
Wire.begin();
multiIoAddExpander ( multiIo, ioFrom8574(0x20, 2), 10); //Add Expander pins 100 - 109
setupMenu();
switches.initialise(multiIo, true);
switches.addSwitchListener(Button1, &keyListenerExpander);
setupRotaryEncoderWithInterrupt(EncoderPinA, EncoderPinB, onEncoderChange, HWACCEL_REGULAR);
}
void loop() {
taskManager.runLoop();
}
void CALLBACK_FUNCTION LeaveMenu(int id) {
// TODO - your menu change code
Serial.println("Leave Menu");
}
The issue is: Using the Encoder to operate the menu does not work: The display shows no move of the cursor to submenus or similar, a test using the Encoder Button for a callback also failed.
void onEncoderChange(int newValue)
{
menuMgr.valueChanged(newValue); // as you are managing things manually, you need to let menu manager know when this changes, unless you've taken over display
}
void onReleased(uint8_t pin, bool held) override {
Serial.println("Released ");
menuMgr.onMenuSelect(wasHeld); // as you are managing things manually, you need to let menu manager know when this changes, unless you've taken over display
}