mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2024-12-04 15:35:32 +00:00
add literal str print in asyncmsg (#2113)
* add literal str print in asyncmsg * remove debug things * accept suggestion per gull * fix documentary
This commit is contained in:
parent
b2da21b88a
commit
03ca87b13e
1
.gitignore
vendored
1
.gitignore
vendored
@ -51,6 +51,7 @@
|
||||
.dep/
|
||||
/build*
|
||||
CMakeFiles/
|
||||
cmake-build-debug/
|
||||
|
||||
# Debugging
|
||||
.gdbinit*
|
||||
|
@ -37,6 +37,8 @@ class UsbSerialAsyncmsg {
|
||||
|
||||
template <typename VECTORCOVER>
|
||||
static void asyncmsg(const std::vector<VECTORCOVER>& data);
|
||||
|
||||
static void asyncmsg(const char* data); // string literal
|
||||
};
|
||||
|
||||
/*Notes:
|
||||
@ -45,15 +47,16 @@ class UsbSerialAsyncmsg {
|
||||
* - so delete all debug things before you push your code to production
|
||||
* - use this client to filter only PP devices: https://github.com/zxkmm/Pyserial-Demo-portapack
|
||||
* - usage:
|
||||
* #include "usb_serial_debug_bridge.hpp"
|
||||
* portapack::async_tx_enabled = true; // note that use this when debugging, unless the msg would be forbidden. but don't use this in production, since it's not real async and multiple serial transmittions will broken each other. if this class is used in other scene in the future, just use command to cover (protect your serial tramsnitton) in your extern thing: asyncmsg enable --- your cmd --- asyncmsg disable
|
||||
* #include "usb_serial_asyncmsg.cpp"
|
||||
* UsbSerialAsyncmsg::asyncmsg("Hello PP");
|
||||
* */
|
||||
|
||||
/// value
|
||||
// to_string_bin/ to_string_decimal/ to_string_hex/ to_string_hex_array/ to_string_dec_uint/ to_string_dec_int etc seems usellss so i didn't add them here
|
||||
// usage: UsbSerialAsyncmsg::asyncmsg(num);
|
||||
|
||||
template <>
|
||||
// usage: UsbSerialAsyncmsg::asyncmsg(num);
|
||||
void UsbSerialAsyncmsg::asyncmsg<int64_t>(const int64_t& data) {
|
||||
if (!portapack::async_tx_enabled) {
|
||||
return;
|
||||
@ -130,6 +133,8 @@ void UsbSerialAsyncmsg::asyncmsg<std::filesystem::path>(const std::filesystem::p
|
||||
}
|
||||
|
||||
/// string
|
||||
|
||||
// string obj
|
||||
template <>
|
||||
// usage: UsbSerialAsyncmsg::asyncmsg(str);
|
||||
void UsbSerialAsyncmsg::asyncmsg<std::string>(const std::string& data) {
|
||||
@ -139,6 +144,15 @@ void UsbSerialAsyncmsg::asyncmsg<std::string>(const std::string& data) {
|
||||
chprintf((BaseSequentialStream*)&SUSBD1, "%s\r\n", data.c_str());
|
||||
}
|
||||
|
||||
// string literal AKA char[]
|
||||
// usage: UsbSerialAsyncmsg::asyncmsg("abc");
|
||||
void UsbSerialAsyncmsg::asyncmsg(const char* data) {
|
||||
if (!portapack::async_tx_enabled) {
|
||||
return;
|
||||
}
|
||||
chprintf((BaseSequentialStream*)&SUSBD1, "%s\r\n", data);
|
||||
}
|
||||
|
||||
/// vec worker
|
||||
// ussgae: UsbSerialAsyncmsg::asyncmsg(vec);
|
||||
template <typename VECTORCOVER>
|
||||
|
Loading…
Reference in New Issue
Block a user