I put together a simple keypad and I2c display to test the flowcode I am going to use to get input from the user. Whilst the display is ok, the kaypad dows not work. I double checked the hardware connections and eventually wired the keypad to different pins, no go!
I looked on Arduino website and found a sketch to test the setup pretty much like mine, so after editing it ran ok and the keypad reported number to the display.
I dont want to lear Arduino as I like flowcode and the way it constructs. So why my FC code is not working when I know the hardware is ok?
I am presuming the Arduino sketch which has include - libraries, it is those libraries which are doing the heavy lifting of setting the port direction and pull up etc.
So around to the question:- does FC have libraries ? and if so how to find a list of them?
If not with the ESP32-Wroom in mind, how do I get access to the registers dealing with pullup and direction?
thanks for reading this
Tink
ESP32 and Libraries
-
- Posts: 25
- http://meble-kuchenne.info.pl
- Joined: Mon Sep 19, 2022 11:19 pm
-
- Valued Contributor
- Posts: 1614
- Joined: Thu Dec 03, 2020 10:57 am
- Has thanked: 357 times
- Been thanked: 565 times
Re: ESP32 and Libraries
Hi
If you post your chart then we can provide better assistance. Just saying "it doesn't work" doesn't give any clue as to why. Flowcode uses components, and within these you can set parameters including pins. Do these match your hardware?
Regards
If you post your chart then we can provide better assistance. Just saying "it doesn't work" doesn't give any clue as to why. Flowcode uses components, and within these you can set parameters including pins. Do these match your hardware?
Regards
Re: ESP32 and Libraries
I uploaded the FC file here:-
https://cloud.tonysteele.uk/index.php/s/KRT4ZE7rmRQGjYf
and the Arduino sketch listing which I used to prove the hardware was connected properly
https://cloud.tonysteele.uk/index.php/s/xYe22xkPz3naQN7
The flowcode sketch is quite simple, wait for a key press, read the number and place in a variable, wait for key release, then print number to the display.
One version I added an led to light after keypress was detected, the hardware permanently lights that led.
I include the Arduino listing as it allows confirmation that the key pad connections are the same for both programs
hope it helps
https://cloud.tonysteele.uk/index.php/s/KRT4ZE7rmRQGjYf
and the Arduino sketch listing which I used to prove the hardware was connected properly
https://cloud.tonysteele.uk/index.php/s/xYe22xkPz3naQN7
The flowcode sketch is quite simple, wait for a key press, read the number and place in a variable, wait for key release, then print number to the display.
One version I added an led to light after keypress was detected, the hardware permanently lights that led.
I include the Arduino listing as it allows confirmation that the key pad connections are the same for both programs
hope it helps
Re: ESP32 and Libraries
Nothing appears in the display using the FC code, and I assume the ports need setting for pullup and direction etc.
I thought FC would have done that simply by adding the keypad ? but maybe not
The code works fine in simulation, but I wanted to ensure the hardware worked before writing lots of code for the application.
Tink
I thought FC would have done that simply by adding the keypad ? but maybe not
The code works fine in simulation, but I wanted to ensure the hardware worked before writing lots of code for the application.
Tink
-
- Valued Contributor
- Posts: 1614
- Joined: Thu Dec 03, 2020 10:57 am
- Has thanked: 357 times
- Been thanked: 565 times
Re: ESP32 and Libraries
Hi
Sorry to be brief.
Any weak pull up would need to be activated/configured "manually". Generally, MCU inbuilt ones are of a high value which may not suit all applications, and also many components have suitable pull-ups already fitted. With FC being target independent it isn't really feasible to try and predict what a user will be connecting the component to nor exact needs.
Your chart does simulate so it is probably hardware related.
Regards
Sorry to be brief.
Any weak pull up would need to be activated/configured "manually". Generally, MCU inbuilt ones are of a high value which may not suit all applications, and also many components have suitable pull-ups already fitted. With FC being target independent it isn't really feasible to try and predict what a user will be connecting the component to nor exact needs.
Your chart does simulate so it is probably hardware related.
Regards
Re: ESP32 and Libraries
Thank you Chipfrier27
Yes I know it is hardware related as the arduino sketch works. The question is how do I switch on the pullup facility and set the port (bit) direction, as I previously stated I believe the arduino Library is setting the conditions that the keypad needs to operate, but no sign of FC libraries. I have not found any information on this subject on the web or within the forum.
cheers all
Tink
Yes I know it is hardware related as the arduino sketch works. The question is how do I switch on the pullup facility and set the port (bit) direction, as I previously stated I believe the arduino Library is setting the conditions that the keypad needs to operate, but no sign of FC libraries. I have not found any information on this subject on the web or within the forum.
cheers all
Tink
-
- Valued Contributor
- Posts: 1614
- Joined: Thu Dec 03, 2020 10:57 am
- Has thanked: 357 times
- Been thanked: 565 times
Re: ESP32 and Libraries
Hi
When you select a component and choose pins etc from properties FC does the rest. For example of you added an LED and connected it to Port A3, then FC automatically configures the chip pin to be an output.
To set weak pull ups you would need to use a "C-Block" to directly set the particular register for the target chip. Offhand I can't tell you which register for an ESP32 as I'm not overly familiar with that chip. No doubt someone else will provide details, but next time I'm in front of one I'll check.
Regards
When you select a component and choose pins etc from properties FC does the rest. For example of you added an LED and connected it to Port A3, then FC automatically configures the chip pin to be an output.
To set weak pull ups you would need to use a "C-Block" to directly set the particular register for the target chip. Offhand I can't tell you which register for an ESP32 as I'm not overly familiar with that chip. No doubt someone else will provide details, but next time I'm in front of one I'll check.
Regards
-
- Valued Contributor
- Posts: 1554
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 138 times
- Been thanked: 741 times
Re: ESP32 and Libraries
See
https://docs.espressif.com/projects/esp ... /gpio.html
I think gpio_set_pull_mode and gpio_pullup_en should do what you are after.
I'll try and make a simple example when I get back to my pc later today.
Martin
https://docs.espressif.com/projects/esp ... /gpio.html
I think gpio_set_pull_mode and gpio_pullup_en should do what you are after.
I'll try and make a simple example when I get back to my pc later today.
Martin
-
- Valued Contributor
- Posts: 1614
- Joined: Thu Dec 03, 2020 10:57 am
- Has thanked: 357 times
- Been thanked: 565 times
Re: ESP32 and Libraries
Hi
I knew I'd seen something regarding pullup.
https://flowcode.co.uk/forums/viewtopic.php?p=493#p493
Regards
I knew I'd seen something regarding pullup.
https://flowcode.co.uk/forums/viewtopic.php?p=493#p493
Regards
-
- Valued Contributor
- Posts: 1554
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 138 times
- Been thanked: 741 times
Re: ESP32 and Libraries
I made a small example based on above and Ben's code...
It uses gpio_pullup_en and gpio_pullup_dis to toggle the pullup resistor on a pin (specified as 'Pin' in properties). So this generates a square wave with 50ms pulses (viewed on the oscilloscope).
So - I wanted to be able to use a 'property'' (rather than a hardcoded pin) - so in this case I use the property's 'create a define' option to create:
#define pin "($PORTA.21)" (Note that for a real application this would probably be a more complicated string than this)
Then in the first code block I use sscanf to extract the pin number (and write it using printf for debug purposes) I've never found a 'simple' way to get a pin number from a property - however this is a fairly easy technique. Edit - - could just use an integer 'pin number' field. However have often wondered about the correct way to do this from a pin definition. Using a 'digitial pin' means that pin = 1 or pin = 0 will work too.
I assign this to 'pin' (a local variable in main) - note that this demonstrates how to access variables in C blocks - using FCL_NAME where NAME is the variable name in capital letters. Globals can be accessed the same way using FCV_NAME.
Note also that I set the pin_mode to be pullup only. This line can be omitted (and then pullup and pull down can be enabled) or pin set to be PULLDOWN_ONLY
Note also that esp32 programs should not 'return' from main(). I usually add a while loop with a delay in to prevent wdt errors at the end of program (if there is an end)
Martin
It uses gpio_pullup_en and gpio_pullup_dis to toggle the pullup resistor on a pin (specified as 'Pin' in properties). So this generates a square wave with 50ms pulses (viewed on the oscilloscope).
So - I wanted to be able to use a 'property'' (rather than a hardcoded pin) - so in this case I use the property's 'create a define' option to create:
#define pin "($PORTA.21)" (Note that for a real application this would probably be a more complicated string than this)
Then in the first code block I use sscanf to extract the pin number (and write it using printf for debug purposes) I've never found a 'simple' way to get a pin number from a property - however this is a fairly easy technique. Edit - - could just use an integer 'pin number' field. However have often wondered about the correct way to do this from a pin definition. Using a 'digitial pin' means that pin = 1 or pin = 0 will work too.
I assign this to 'pin' (a local variable in main) - note that this demonstrates how to access variables in C blocks - using FCL_NAME where NAME is the variable name in capital letters. Globals can be accessed the same way using FCV_NAME.
Note also that I set the pin_mode to be pullup only. This line can be omitted (and then pullup and pull down can be enabled) or pin set to be PULLDOWN_ONLY
Note also that esp32 programs should not 'return' from main(). I usually add a while loop with a delay in to prevent wdt errors at the end of program (if there is an end)
Martin