Where to find the needed include-files?
Hello, I tried to get the STM32 code up and running, but I already struggle with getting it compiled (Arduino IDE).
There are two includes mentioned, where I am not sure, where to find them:
#include <USBComposite.h> #include <Button.h> // https://github.com/JChristensen/Button
When checking https://github.com/JChristensen/Button, there is file listed in the src-folder, called "JC_Button.h". Is it this one? So I just need to rename it?
But where might I find the USBComposite.h?
Thanks a lot for your help.
Hi, are you using the right core for the STM32? That should be https://github.com/rogerclarkmelbourne/Arduino_STM32 which includes a USBComposite.h. And for the button library, I found this folder in my Arduino library directory: Button.zip The library must have been renamed to JC_Button later and I was using an ancient version.
Hello,
thanks a lot for the Button.zip. :)
I still struggle with getting the code up and running - right now I just try to get the code compiled only, to take step by step the next steps. I have to admit, that I am neither an arduino IDE nor an C-expert. :( I have installed Arduino IDE (2.3.4). Then I downloaded the Arduino_STM32-master.zip from https://github.com/rogerclarkmelbourne/Arduino_STM32 and copied the content from within the zip-file to the Documents\Arduino\hardware folder of the user (Windows 11) - as described in the related wiki. Here I renamed the folder from Arduino_STM32-master to Arduino_STM32. BTW: I tried to add the repository via file/preferences in the Arduino IDE as well (https://github.com/rogerclarkmelbourne/Arduino_STM32.git) - no difference. Documents\Arduino\libraries is containing: Adafruit_BusIO, Adafruit_GFX_Library, Adafruit_SSD1306, the Button folder you provided.
When I now start compiling, I get this error still: G:\keybon\keybon.ino:1:10: fatal error: USBComposite.h: No such file or directory 1 | #include <USBComposite.h> | ^~~~~~~~~~~~~~~~ compilation terminated. exit status 1
Compilation error: USBComposite.h: No such file or directory_
Do I need to register the files somewhere? Or is it the wrong place? Or do I just need to place an extract of the Arduino_STM32- content?
Really looking forward to your help. Thanks a lot.
I can try to compile it on the weekend. It's been a while since I programmed the STM32. The folder structure should be Documents/Arduino/hardware/Arduino_STM32/drivers, tools, etc... And are you sure you selected the right device from the board menu?
Oh, maybe I have chosen the wrong device. I selected "Generic STM32F1 series" from "STM32 MPU based boards". Now, when selecting from "STM32F1 Boards (Arduino_STM32) (in Sketchbook), I have set these settings:
When now compiling, I get another issue: exec: "/bin/arm-none-eabi-g++": executable file not found in %PATH% Compilation error: exec: "/bin/arm-none-eabi-g++": executable file not found in %PATH%
BTW: What to be done with the "STM32duino-bootloader", after downloading?
"STM32 flasher" was relaced by STM32CubeProgrammer. I assume, I need to load the binary into STM32CubeProgrammer and then flash it to the STM32. But what binary to be taken?
And what exactly do I need to add here?
Sorry for all these questions.
Wow, there were a lot of things I had to fix: As I am using Windows 11, and Arduino IDE 2.3.4, I had to install the Java Runtime (32bit) as well. I reinstalled the STM32 driver again and then I was able to compile the code and send it to the STM32 :)
It seems to work now. The STM32 is identified as keyboard (right now I am using for testing a BluePill Development board with STM32F103C8T6). When pulling one of the keay-pins to low, the related key is sent to the computer. All keystrokes define in the STM32 code seem to work. I do not have the displays in place yet, so this part need to wait some more time.
When using the Windows programm (keybon companion), the com-port is identified correctly, but when defining another layout, still the default key-strokes are processed (key-strokes as coded in the STM). The Windows program (Keybon companion) notices what program gets activated, but still the default keys are send. Any idea?
Great, I'm glad that you got it to compile! And flashing the bootloader can be tricky, too. About the key functions: I just plugged in my keybon and ran the .exe from this github page. The keys do work as expected for me. The companion software always goes back to the default layout if no process was linked. And of course it's important to have the right COM port selected. Because the default keystrokes will always work through the HID interface, but custom key strokes require a serial connection.
I compile your code via Visual Studio and started it. Default keystrokes are working fine, but not the custom ones. Can it be an issue, not having your board, but for initial test-purposes the BluePill Development board with STM32F103C8T6? It feels like the serial connection is an issue, although the Com-port is shown up in the Device manager of Windows and I selected this port in the app as well.
I don't see why the bluepill should work differently from the keybon board. Have you tried the compiled exe from GitHub?
I tried, but Windows 11 is blocking it. It cannot be executed (security warning). I need to find out how to disable the warning.
When now testing the compiled exe you shared on github, I still have the same issue: Default only is working.
When now starting via Debug-mode (Visual Studio 2022 - 64bit), _serialPort. is causing issues: Ausnahme ausgelöst: "System.InvalidOperationException" in System.dll Ein Ausnahmefehler des Typs "System.InvalidOperationException" ist in System.dll aufgetreten. Der Anschluss ist geschlossen. Das Programm "[2748] keybon companion.exe" wurde mit Code 4294967295 (0xffffffff) beendet. Seems like the serial port isn't connected correctly.
I have only one COM-port listed in device-manager: COM5. This is shown in the app as well:
When debugging, the app always trys to go via COM14:
And then the system is skipping this part:
When just hard-coding the COM-port for test-purposes, it seems to work:
As I am not a C#-expert, I wonder about how to fix this. Any suggestions about what to do?
UPDATE: It feels like this problem is relevant only, if having only one COM-port in sum in the system.
Sorry, I missed your edit. Interesting find, maybe I never noticed this because my PC usually has an unused COM1. COM14 is the default port (portName) that I must have used for testing. The port is actually set via the dropdown here:
private void comboBox2_SelectionChangeCommitted(object sender, EventArgs e)
{
_serialPort.Close();
_serialPort.PortName = comboBox2.SelectedItem.ToString();
try
{
_serialPort.Open();
}
catch { }
}
At some point, the portName string should be overwritten by the settings, because the program remembers the COM port and screen layout. But it's been a few years and that is my only C# project so far. :)
No worries. Quite impressive, that this was your first and only C# program 👍 I have never done any coding in C# so far, but as your project is so interested, I tried to dig a little into it. I did some adjustments in the version I downloaded:
- alphabetical sorting of items in the list-boxes (showing all and the assigned programs)
- assigning the COM port again, chosen last time
- adding '-' to the COM-port and list it as default, when starting first time
I just noticed in the "Pull requests" section, that slimline33 did some enhancements as well. Are these adjustments part of the code presented in GitHub already? Is there a difference in the code provided in this code-section https://github.com/CoretechR/Keybon compared to https://github.com/CoretechR/Keybon/releases/tag/1.0 ?
Oh no, I forgot about the pull request 😱 I could not get it to run last month but it seems like slimline33 made some updates. This should definitely be included in the main branch. You can of course create a pull request with your changes, too.
I will do my best, as I am new about this as well. Let me know, when changes of slimline33 have been tested and are working fine. Then I will compare it with my adjustments and add my changes.
How are things going. Has the code been updated?
I just noticed something different while testing: For me it looks like the display is updating the content(icons) twice, when switching to another Windows app. I haven't found yet the code snippet, where the update to the STM32 is being triggered, when switching to another Windows app. Can anybody help?
I just wanted to chime in, having just built my first keybon (with help, though) - the companion app does not work for me as well, it seems to be unable to communicate with they keybon. The serial port is COM24 in that case and it is connected, but the companion app is giving me this:
Thanks all!
And I stumbled upon a workyround: When putting in some other COM-Port, you can then switch again to the one offered - for some reason, it is now sticking.