My sleeping feature is based on this example: https://www.reddit.com/r/watchX/comments/8vjciw/watch_code_with_sleep_and_interruptbased_waking/
As you proposed I made some trials with other libraries such as avr interrupt.h . But no success. Isn’t it possible to attach interupts without a library?
I will try to find a solution, if I can’t I may edit the BLE library or the Interrupt library;)
As far as I know i don‘t use an interrupt library within TapClock for the MPU Interrupt.
Just attach and detach commands.
Found here: https://www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/
Still fighting with the old problem. As mtulu proposed I tried another library for the interrupts. It is the same venice1200 used in the WordClock Mode of his TapClock example (PinChangeInterrupt from https://github.com/NicoHood/PinChangeInterrupt). This allows wakeup by a button. In my example sketch it works fine. See: https://github.com/micha01/watchX-ButtonInterrupt-BLE
But as soon as the Adafruit_BLE.h will be included the same error appears as I had with the EnableInterrupt.h library (see above).
Is there a way to use Adafruit_BLE and Button wakeup in the same sketch?
As far as I know you need to use PinChangeInterrupt for the Buttons and the “normal” Interrupt statements for the BLE/MPU and RTC.
But I can’t get the BLE to work only MPU and RTC.
When googeling it appears that this is a conflict with the SoftwareSerial.h. SoftwareSerial seems to occupy all PinChange interrupts. There are some general proposals to use other libraries instead (AltSoftSerial, NeoSWSerial etc.), but I am not experienced enough to adopt this. In other words to make the changes in the affected libraries (for example SoftwareSerial.h, Adafruit_Ble.h, PinChangeInterrupt.h). Any help?
PROBLEM SOLVED: There is a solution to avoid the conflict between the bluetooth library Adafruit_BLE.h and libraries for pin changes such as PinChangeInterrupt.h or EnableInterrupt.h. As mentioned above the underlaying SoftwareSerial.h is the troubleshooter.
Just comment out the line “ #define SOFTWARE_SERIAL_AVAILABLE … “ in Adafruit_BluefruitLE_UART.h library:
That’s it. Now it is possible to use bluetooth and a wake up (interrupt) button in the same sketch and watchX application.
Great finding…
Wow! An amazing solution! Thank you!
Could you add it to the Coding tips & tricks section please
I made an example in education section.
Video video video
Thanks Mustafa, shared a video here
Wow, let me try!
We don’t have an ev3 at the office; however, I have searched on the internet and it can connect the ev3 as a controller. You need to initilise the watchX as BT Keyboard and send commands such as bluetooth keyboard key press.
Can you please try the attached scratch code? Once the ev3 received the w key press you should code it to make an action.
Link:https://drive.google.com/file/d/1a-ro2VvoD3gON9vyHVo5hcxzJjD5uDGx/view?usp=sharing
It appears that the ev3 does not detect the watchx for some reason, even though it is set as a keyboard
Is there a way that you can check if it connects to other Bluetooth keyboards?
Link to the code please! I really think this project looks cool, it would be cool to control a robot with my watchX. Please reply w/ a link to the code.