[Logo] TCC discussion forum
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Top Downloads] Top Downloads   [Groups] Back to home page 
[Register] Register /  [Login] Login 


This forum is read only and new users cannot register, please ask all new questions either using GitHub discussions, or in Arduino forum tagging @davetcc.

MultiIO abstraction and Encoder setup RSS feed
Forum Index » IoAbstraction & TaskManagerIO
Author Message
FS


Joined: Mar 19, 2021
Messages: 6
Offline
Hello,
being struggeling with the use of multiIO-abstraction and encoder.

Encoder is wired to an 8574 Expander, the expander INT-Pin is connected to Pin 2 of an ESP 8266 to get an interrupt.

Doing now some tests with this combination but running into problems.

i.) Operating the expander without multiIo using ioFrom8574 makes the expander work without any problems
ii.) Changing to multiIo doesn't let me allow to use the rotaries.
A test to define the PinA +PinB as switch using multiIO shows that both are operational.
iii.) Defining multiIo as reference in TCMenu has as effect the Encoder doesn't allow to change menu items. Also here: Push button switch works fine.

Do i have to define somehow Interrupts ? My understanding is the IvAbstraction does provide that service.

Attached the actual code.

#include <IoAbstraction.h>
#include <IoAbstractionWire.h>
#include <TaskManagerIO.h>
#include <Wire.h>



// to make life easier, probably define each expander
    #define EXPANDER1 100

// Multi IO generieren mit Pin 0 - 99 für ESP8266
    MultiIoAbstractionRef multiIo = multiIoExpander(EXPANDER1);


//Encoder
    const uint8_t encoderAPin = 101;
    const uint8_t encoderBPin = 102;
    
    // the maximum value (starting from 0) that we want the encoder to represent. This range is inclusive.
    const int maximumEncoderValue = 1000;
    


// Each time the encoder value changes, this function runs, as we registered it as a callback
//
void onEncoderChange(int newValue) {
    Serial.print("Encoder change ");
    Serial.println(newValue);
}


void onSwitchPressed(uint8_t key, bool held) 
  {
    
    ioDeviceSync(multiIo); // force another sync
  
    Serial.print("Switch "); 
    Serial.print(key);
    Serial.println(held ? " Held down" : " Pressed");
  }



class RepeatButtonListener : public SwitchListener {
private:
    int counter;
public:
    void onPressed(pinid_t pin, bool held) override {
        ++counter;
        Serial.print("Repeat button pressed ");
        Serial.println(counter);
    }

    void onReleased(pinid_t pin, bool held) override {
        Serial.print("Released after presses ");
        Serial.println(counter);
        counter = 0;
    }
} repeatListener;




void setup() 
  {
          Wire.begin();

          //Serielle Sxchnittstelle und Monitor
          Serial.begin(9600);
          Serial.println(" Start Setup");

       

          //8574 Expander added, 10 Pin 100 - 109
          multiIoAddExpander ( multiIo, ioFrom8574(0x20), 10);          
          Serial.println("expander 8574:  Pin 100 bis 109 hinzu über multiIoAddExpander");

          
          // Pin 8574 definition of Pins
          
                ioDevicePinMode(multiIo, EXPANDER1,   INPUT);  //P0
                ioDevicePinMode(multiIo, EXPANDER1+0, INPUT);  //P1 Pin 100 ( P0 auf 8574) Taster
                ioDevicePinMode(multiIo, EXPANDER1+1, INPUT);  //P2 Pin 101 Encoder Pin A
                ioDevicePinMode(multiIo, EXPANDER1+2, INPUT);  //P3 Pin 102 Encoder Pin B
                ioDevicePinMode(multiIo, EXPANDER1+3, INPUT);  //P4 Pin 103 ( P3 auf 8574) Taster Drehimpulsgeber
                
              
        Serial.println("ioDevicePinMode für Pin 100 + 103 hinzu");
        Serial.println("Multi IoExpander example");
        Serial.println("Io is setup, adding switch");
                
                
                switches.initialise(multiIo, true);
                switches.addSwitch(EXPANDER1 +0, onSwitchPressed);
                switches.addSwitch(EXPANDER1 +3, onSwitchPressed);  
                /*
                switches.addSwitch(EXPANDER1 +1, onSwitchPressed); //Test CLK / PinA as switch
                switches.addSwitch(EXPANDER1 +2, onSwitchPressed); //Test DT / PinB
                */

    
    setupRotaryEncoderWithInterrupt(encoderAPin, encoderBPin, onEncoderChange, HWACCEL_REGULAR);
    
    switches.changeEncoderPrecision(0, 0);


        
       Serial.println("setup is done!");
  }





void loop() 
  {
  
    taskManager.runLoop();
  
    
  }

FS


Joined: Mar 19, 2021
Messages: 6
Offline
Sorry,
as always: Testing three-four days, reading a lot, doing notes before something gets addressed to a forum.
And just after the announcement the bug got found:

multiIoAddExpander ( multiIo, ioFrom8574(0x20, 2), 10);

means the interrupt pin of the ESP 8266 wasn't addressed properly.

davetcc


Joined: Jan 19, 2019
Messages: 686
Offline
No problem, are you all good with it now?
FS


Joined: Mar 19, 2021
Messages: 6
Offline
All good now - further fighting ongoing as coding is not really my profession....last time it was Fortran77 tow decades before. But I really wanna say thanks for your work and all the fantastic functions of the framework.
 
Forum Index » IoAbstraction & TaskManagerIO
Go to:   
Mobile view
Powered by JForum 2.7.0 © 2020 JForum Team • Maintained by Andowson Chang and Ulf Dittmer

This site uses cookies to analyse traffic, serve ads by Google AdSense (non-personalized in EEA/UK), and to record consent. We also embed Twitter, Youtube and Disqus content on some pages, these companies have their own privacy policies.

Our privacy policy applies to all pages on our site

Should you need further guidance on how to proceed: External link for information about cookie management.