├── src ├── CommSink.cpp ├── SUIPlatNRF52Arduino.cpp ├── CommSource.cpp ├── includes │ ├── comm │ │ ├── channels.h │ │ ├── CommSink.h │ │ ├── ChannelManager.h │ │ ├── CommSource.h │ │ ├── CommRequest.h │ │ ├── CommChannel.h │ │ └── CommFieldBoundaries.h │ ├── tracked │ │ ├── tracked.h │ │ ├── TrackedString.h │ │ └── TrackedNum.h │ ├── SerialUIExtIncludes.h │ ├── SerialUIStrings.h │ ├── platform │ │ ├── linux │ │ │ ├── LinuxMain.h │ │ │ ├── SUILinuxSupport.h │ │ │ ├── LinuxExtIncludes.h │ │ │ ├── LinuxBLESerial.h │ │ │ ├── LinuxStorageFilesystem.h │ │ │ └── LinuxPrint.h │ │ ├── nrf52 │ │ │ ├── NRF52BLESerial.h │ │ │ └── BLESerial.h │ │ ├── SUIPlatLinux.h │ │ ├── SUIPlatNRF52Arduino.h │ │ ├── SUIPlatArduino.h │ │ └── detect │ │ │ └── XMegaDetection.h │ ├── menuitem │ │ ├── items.h │ │ ├── SubGroup.h │ │ ├── ItemList.h │ │ ├── requests │ │ │ ├── requests.h │ │ │ ├── ItemReqDateTime.h │ │ │ ├── ItemReqCharacter.h │ │ │ ├── ItemReqFloat.h │ │ │ ├── ItemReqLong.h │ │ │ ├── ItemReqUnsignedLong.h │ │ │ ├── externalPythonValidation.h │ │ │ ├── ItemReqString.h │ │ │ ├── ItemReqColor.h │ │ │ ├── ItemReqBoolean.h │ │ │ ├── ItemReqPassphrase.h │ │ │ ├── ItemReqBoundedLong.h │ │ │ ├── ItemReqOptions.h │ │ │ ├── ItemReqTime.h │ │ │ └── ItemReqEvent.h │ │ ├── ItemCommand.h │ │ ├── ItemText.h │ │ ├── trackedview │ │ │ └── trackedviews.h │ │ ├── ItemDynamicText.h │ │ ├── ItemTrackedView.h │ │ ├── MenuItem.h │ │ └── SubMenu.h │ ├── auth │ │ ├── AuthTypes.h │ │ ├── AuthStorage.h │ │ ├── AuthSimple.h │ │ ├── AuthValidator.h │ │ ├── AuthStoragePython.h │ │ ├── AuthValidatorEquality.h │ │ ├── AuthValidatorPython.h │ │ ├── AuthStorageStatic.h │ │ └── Authenticator.h │ ├── settings │ │ ├── StateStorage.h │ │ ├── DeSerializerJson.h │ │ ├── DeSerializer.h │ │ └── Serializer.h │ ├── menu │ │ ├── Tracking.h │ │ └── MenuStructure.h │ ├── strings │ │ └── SUIStrings_en.h │ ├── python │ │ ├── pyhelper.hpp │ │ └── ExternalModule.h │ ├── SUIGlobals.h │ ├── SerialUIPlatform.h │ ├── Menu.h │ ├── SerialUIConfig.h │ ├── GrowableList.h │ ├── SUIState.h │ └── SerialUITypes.h ├── CommChannel.cpp ├── Menu.cpp ├── AuthStorage.cpp ├── LinuxMain.cpp ├── AuthValidator.cpp ├── ItemText.cpp ├── SubGroup.cpp ├── ItemList.cpp ├── AuthSimple.cpp ├── Tracking.cpp ├── SUIPlatArduino.cpp ├── TrackedVariable.cpp ├── ItemReqDateTime.cpp ├── ItemReqCharacter.cpp ├── CommRequest.cpp ├── ItemCommand.cpp ├── ItemDynamicText.cpp ├── ItemReqFloat.cpp ├── ItemReqLong.cpp ├── ItemTrackedView.cpp ├── ChannelManager.cpp ├── SUIState.cpp ├── LinuxStorageFilesystem.cpp ├── ItemReqUnsignedLong.cpp ├── Authenticator.cpp ├── MenuItem.cpp ├── ItemReqString.cpp ├── LinuxBLESerial.cpp ├── ItemReqTime.cpp ├── AuthStoragePython.cpp ├── SUILinuxSupport.cpp ├── ItemReqBoolean.cpp ├── ItemRequest.cpp ├── AuthValidatorEquality.cpp ├── AuthValidatorPython.cpp ├── AuthStorageStatic.cpp ├── SerialUI.h ├── SUIGlobals.cpp ├── ItemReqEvent.cpp ├── ItemReqBoundedLong.cpp ├── CMakeLists.txt ├── ItemReqOptions.cpp ├── MenuStructure.cpp └── TrackedString.cpp ├── library.properties ├── extras └── INSTALL.txt ├── keywords.txt ├── examples ├── BasicUI │ ├── BasicUISettings.h │ └── BasicUI.h ├── BasicAuth │ ├── BasicAuthSettings.h │ └── BasicAuth.h ├── Graphin │ └── GraphinSettings.h └── AllWidgets │ └── AllWidgetsSettings.h └── README.md /src/CommSink.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * CommSink.cpp 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * CommSink is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #include "includes/comm/CommSink.h" 12 | 13 | namespace SerialUI { 14 | namespace Comm { 15 | 16 | 17 | } /* namespace Comm */ 18 | } /* namespace SerialUI */ 19 | -------------------------------------------------------------------------------- /src/SUIPlatNRF52Arduino.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SUIPlatNRF52Arduino.cpp 3 | * 4 | * Created on: Oct 13, 2018 5 | * Author: Pat Deegan 6 | * 7 | * SUIPlatNRF52Arduino is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | 12 | #include "includes/SerialUIPlatform.h" 13 | 14 | #ifdef SERIALUI_PLATFORM_NRF52 15 | 16 | // BLESerial SUIBLESerialDev = BLESerial(); 17 | 18 | #endif 19 | 20 | -------------------------------------------------------------------------------- /src/CommSource.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * CommSource.cpp 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * CommSource is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | #include "includes/comm/CommSource.h" 11 | 12 | namespace SerialUI { 13 | namespace Comm { 14 | 15 | Source::Source() : SourceBase() { 16 | } 17 | 18 | 19 | } /* namespace Comm */ 20 | } /* namespace SerialUI */ 21 | -------------------------------------------------------------------------------- /src/includes/comm/channels.h: -------------------------------------------------------------------------------- 1 | /* 2 | * channels.h 3 | * 4 | * Created on: May 27, 2018 5 | * Author: Pat Deegan 6 | * 7 | * channels is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUI_SRC_INCLUDES_COMM_CHANNELS_H_ 12 | #define SERIALUI_SRC_INCLUDES_COMM_CHANNELS_H_ 13 | 14 | 15 | #include "CommChannelArdStd.h" 16 | 17 | 18 | #endif /* SERIALUI_SRC_INCLUDES_COMM_CHANNELS_H_ */ 19 | -------------------------------------------------------------------------------- /src/CommChannel.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * CommChannel.cpp 3 | * 4 | * Created on: May 27, 2018 5 | * Author: Pat Deegan 6 | * 7 | * CommChannel is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #include "includes/comm/CommChannel.h" 12 | 13 | namespace SerialUI { 14 | namespace Comm { 15 | 16 | Channel::Channel(Mode::Selection forMode) : _mode(forMode) { 17 | 18 | } 19 | 20 | } /* namespace Comm */ 21 | } /* namespace SerialUI */ 22 | -------------------------------------------------------------------------------- /src/includes/tracked/tracked.h: -------------------------------------------------------------------------------- 1 | /* 2 | * tracked.h 3 | * 4 | * Created on: May 26, 2018 5 | * Author: Pat Deegan 6 | * 7 | * tracked is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUI_SRC_INCLUDES_TRACKED_TRACKED_H_ 12 | #define SERIALUI_SRC_INCLUDES_TRACKED_TRACKED_H_ 13 | 14 | 15 | #include "TrackedNum.h" 16 | #include "TrackedString.h" 17 | 18 | 19 | #endif /* SERIALUI_SRC_INCLUDES_TRACKED_TRACKED_H_ */ 20 | -------------------------------------------------------------------------------- /src/includes/SerialUIExtIncludes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SerialUIExtIncludes.h 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * SerialUIExtIncludes is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUIV3_SRC_INCLUDES_SERIALUIEXTINCLUDES_H_ 12 | #define SERIALUIV3_SRC_INCLUDES_SERIALUIEXTINCLUDES_H_ 13 | 14 | 15 | #include 16 | #include "SerialUIPlatform.h" 17 | 18 | #endif /* SERIALUIV3_SRC_INCLUDES_SERIALUIEXTINCLUDES_H_ */ 19 | -------------------------------------------------------------------------------- /src/Menu.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Menu.cpp 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * Menu is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #include "includes/Menu.h" 12 | 13 | namespace SerialUI { 14 | namespace Menu { 15 | 16 | Menu::Menu() { 17 | // TODO Auto-generated constructor stub 18 | 19 | } 20 | 21 | Menu::~Menu() { 22 | // TODO Auto-generated destructor stub 23 | } 24 | 25 | } /* namespace Menu */ 26 | } /* namespace SerialUI */ 27 | -------------------------------------------------------------------------------- /src/AuthStorage.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * AuthStorage.cpp 3 | * 4 | * Created on: Jun 6, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | #include "includes/auth/AuthStorage.h" 14 | 15 | namespace SerialUI { 16 | namespace Auth { 17 | 18 | Storage::Storage() { 19 | 20 | } 21 | 22 | Storage::~Storage() { 23 | } 24 | 25 | } /* namespace Auth */ 26 | } /* namespace SerialUI */ 27 | -------------------------------------------------------------------------------- /src/includes/SerialUIStrings.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SerialUIStrings.h 3 | * 4 | * Created on: May 28, 2018 5 | * Author: Pat Deegan 6 | * 7 | * SerialUIStrings is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUI_SRC_INCLUDES_SERIALUISTRINGS_H_ 12 | #define SERIALUI_SRC_INCLUDES_SERIALUISTRINGS_H_ 13 | 14 | #include "SerialUIConfig.h" 15 | 16 | #ifdef SERIALUI_LANGUAGE_EN 17 | #include "strings/SUIStrings_en.h" 18 | #endif 19 | 20 | 21 | 22 | #endif /* SERIALUI_SRC_INCLUDES_SERIALUISTRINGS_H_ */ 23 | -------------------------------------------------------------------------------- /src/LinuxMain.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * LinuxMain.cpp 3 | * 4 | * Created on: Apr 27, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | 14 | #include "includes/SerialUIPlatform.h" 15 | 16 | #ifdef SERIALUI_PLATFORM_LINUX 17 | 18 | #include "includes/platform/linux/LinuxMain.h" 19 | 20 | int main(int argc, char **ppArgv) { 21 | devicedruidmain(argc, ppArgv); 22 | } 23 | 24 | #endif /* SERIALUI_PLATFORM_LINUX */ 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/AuthValidator.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * AuthValidator.cpp 3 | * 4 | * Created on: Jun 6, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | 14 | #include "includes/auth/AuthValidator.h" 15 | 16 | namespace SerialUI { 17 | namespace Auth { 18 | 19 | Validator::Validator(Storage * storage) : auth_store(storage) { 20 | 21 | 22 | } 23 | 24 | Validator::~Validator() { 25 | } 26 | 27 | } /* namespace Auth */ 28 | } /* namespace SerialUI */ 29 | -------------------------------------------------------------------------------- /src/includes/platform/linux/LinuxMain.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LinuxMain.cpp 3 | * 4 | * Created on: Apr 27, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | #ifndef SERIALUI_SRC_INCLUDES_PLATFORM_LINUX_LINUXMAIN_CPP_ 14 | #define SERIALUI_SRC_INCLUDES_PLATFORM_LINUX_LINUXMAIN_CPP_ 15 | 16 | 17 | #include "LinuxExtIncludes.h" 18 | 19 | int main (int argc, char **ppArgv); 20 | 21 | 22 | 23 | #endif /* SERIALUI_SRC_INCLUDES_PLATFORM_LINUX_LINUXMAIN_CPP_ */ 24 | -------------------------------------------------------------------------------- /src/ItemText.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ItemText.cpp 3 | * 4 | * Created on: May 31, 2018 5 | * Author: Pat Deegan 6 | * 7 | * ItemText is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #include "includes/menuitem/ItemText.h" 12 | 13 | namespace SerialUI { 14 | namespace Menu { 15 | namespace Item { 16 | Text::Text(StaticString t, StaticString c) 17 | : Item(Type::StaticText, t, c) { 18 | 19 | } 20 | Text::Text(ID id, StaticString t, StaticString c) 21 | : Item(id, Type::StaticText, t, c) { 22 | 23 | } 24 | 25 | } /* namespace Item */ 26 | } /* namespace Menu */ 27 | } /* namespace SerialUI */ 28 | -------------------------------------------------------------------------------- /src/includes/menuitem/items.h: -------------------------------------------------------------------------------- 1 | /* 2 | * items.h 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * items is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUIV3_SRC_INCLUDES_MENUITEM_ITEMS_H_ 12 | #define SERIALUIV3_SRC_INCLUDES_MENUITEM_ITEMS_H_ 13 | 14 | 15 | #include "ItemCommand.h" 16 | #include "requests/requests.h" 17 | #include "SubMenu.h" 18 | #include "ItemDynamicText.h" 19 | #include "ItemText.h" 20 | #include "SubGroup.h" 21 | #include "ItemList.h" 22 | #include "trackedview/trackedviews.h" 23 | 24 | 25 | 26 | #endif /* SERIALUIV3_SRC_INCLUDES_MENUITEM_ITEMS_H_ */ 27 | -------------------------------------------------------------------------------- /src/includes/comm/CommSink.h: -------------------------------------------------------------------------------- 1 | /* 2 | * CommSink.h 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * CommSink is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUIV3_SRC_INCLUDES_COMMSINK_H_ 12 | #define SERIALUIV3_SRC_INCLUDES_COMMSINK_H_ 13 | #include "../SerialUIPlatform.h" 14 | 15 | namespace SerialUI { 16 | namespace Comm { 17 | 18 | typedef SinkBase Sink; 19 | /* 20 | 21 | class Sink : public virtual SinkBase { 22 | public: 23 | Sink(); 24 | // virtual ~Sink() {} 25 | 26 | 27 | }; 28 | */ 29 | 30 | } /* namespace Comm */ 31 | } /* namespace SerialUI */ 32 | 33 | #endif /* SERIALUIV3_SRC_INCLUDES_COMMSINK_H_ */ 34 | -------------------------------------------------------------------------------- /src/SubGroup.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SubGroup.cpp 3 | * 4 | * Created on: Oct 1, 2018 5 | * Author: Pat Deegan 6 | * 7 | * SubGroup is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #include "includes/menuitem/SubGroup.h" 12 | 13 | namespace SerialUI { 14 | namespace Menu { 15 | namespace Item { 16 | 17 | 18 | Group::Group(ID parentId, StaticString key, StaticString help) : 19 | SubMenu(parentId, key, help) { 20 | setType(Type::Group); 21 | } 22 | Group::Group(ID id, ID parentId, StaticString key, StaticString help) : 23 | SubMenu(id, parentId, key, help) { 24 | setType(Type::Group); 25 | } 26 | 27 | } /* namespace Item */ 28 | } /* namespace Menu */ 29 | } /* namespace SerialUI */ 30 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=SerialUI 2 | version=3.1.0 3 | author=Pat Deegan 4 | maintainer=Pat Deegan 5 | sentence=A user interface through the serial channel (menus, sub-menus and command execution), with support for navigation through the menu hierarchy and online help. 6 | paragraph=With SerialUI, you can create a hierarchy of menus and submenus of arbitrary depth (limited only by ROM/RAM space). Each menu contains a list of menu items, which are either sub-menus (lead you to another level of menu items) or commands (actually perform some type of action). Exactly what happens when a user issues a command is determined by your callbacks. 7 | category=Communication 8 | url=https://devicedruid.com/ 9 | architectures=* 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/includes/menuitem/SubGroup.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SubGroup.h 3 | * 4 | * Created on: Oct 1, 2018 5 | * Author: Pat Deegan 6 | * 7 | * SubGroup is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUI_SRC_INCLUDES_MENUITEM_SUBGROUP_H_ 12 | #define SERIALUI_SRC_INCLUDES_MENUITEM_SUBGROUP_H_ 13 | #include "SubMenu.h" 14 | namespace SerialUI { 15 | namespace Menu { 16 | namespace Item { 17 | 18 | class Group : public SubMenu { 19 | public: 20 | 21 | Group(ID parentId, StaticString key, StaticString help); 22 | Group(ID id, ID parentId, StaticString key, StaticString help); 23 | 24 | }; 25 | 26 | } /* namespace Item */ 27 | } /* namespace Menu */ 28 | } /* namespace SerialUI */ 29 | 30 | #endif /* SERIALUI_SRC_INCLUDES_MENUITEM_SUBGROUP_H_ */ 31 | -------------------------------------------------------------------------------- /src/ItemList.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * List.cpp 3 | * 4 | * Created on: Apr 29, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | #include "includes/menuitem/ItemList.h" 14 | 15 | namespace SerialUI { 16 | namespace Menu { 17 | namespace Item { 18 | 19 | 20 | 21 | List::List(ID parentId, StaticString key, StaticString help) : 22 | SubMenu(parentId, key, help) { 23 | setType(Type::List); 24 | } 25 | 26 | List::List(ID id, ID parentId, StaticString key, StaticString help) : 27 | SubMenu(id, parentId, key, help) { 28 | setType(Type::List); 29 | } 30 | 31 | } /* namespace Item */ 32 | } /* namespace Menu */ 33 | } /* namespace SerialUI */ 34 | -------------------------------------------------------------------------------- /src/AuthSimple.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * AuthSimple.cpp 3 | * 4 | * Created on: Jun 6, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | #include "includes/auth/AuthSimple.h" 14 | 15 | #ifdef SERIALUI_AUTHENTICATOR_ENABLE 16 | 17 | namespace SerialUI { 18 | namespace Auth { 19 | 20 | Simple::Simple(Passphrase adminPass, Passphrase userPass, 21 | Passphrase guestPass) : 22 | pass_store(adminPass, userPass, guestPass), 23 | eq_validator(&pass_store), 24 | Authenticator(&eq_validator) 25 | { 26 | 27 | 28 | } 29 | 30 | 31 | } /* namespace Auth */ 32 | } /* namespace SerialUI */ 33 | 34 | 35 | #endif /* SERIALUI_AUTHENTICATOR_ENABLE */ 36 | -------------------------------------------------------------------------------- /src/Tracking.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Tracking.cpp 3 | * 4 | * Created on: May 26, 2018 5 | * Author: Pat Deegan 6 | * 7 | * Tracking is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | 12 | #include "includes/menu/Tracking.h" 13 | #include "includes/SerialUIPlatform.h" 14 | 15 | namespace SerialUI { 16 | namespace Menu { 17 | 18 | Tracking::Tracking(uint8_t numItems) : 19 | GrowableList(numItems) { 20 | } 21 | 22 | Tracked::State * Tracking::itemByName(DynamicString aKey) { 23 | for (uint8_t i=0; iname(), aKey, false)) { 26 | return st; 27 | } 28 | } 29 | 30 | return NULL; 31 | } 32 | 33 | } /* namespace Menu */ 34 | } /* namespace SerialUI */ 35 | -------------------------------------------------------------------------------- /src/includes/platform/linux/SUILinuxSupport.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SUILinuxSupport.cpp 3 | * 4 | * Created on: Apr 27, 2019 5 | * Author: Pat Deegan 6 | * 7 | * SUILinuxSupport is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUI_SRC_INCLUDES_PLATFORM_LINUX_SUILINUXSUPPORT_H_ 12 | #define SERIALUI_SRC_INCLUDES_PLATFORM_LINUX_SUILINUXSUPPORT_H_ 13 | 14 | 15 | #include "../SUIWString.h" 16 | #include "LinuxExtIncludes.h" 17 | #include "LinuxStream.h" 18 | 19 | 20 | unsigned long int millis(void); 21 | unsigned long int micros(void); 22 | void delay(unsigned long int d); 23 | void delayMicroseconds(unsigned long int us); 24 | unsigned long random(unsigned long minOrMax, unsigned long max); 25 | 26 | #endif /* SERIALUI_SRC_INCLUDES_PLATFORM_LINUX_SUILINUXSUPPORT_H_ */ 27 | -------------------------------------------------------------------------------- /src/includes/platform/linux/LinuxExtIncludes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LinuxExtIncludes.h 3 | * 4 | * Created on: Apr 27, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | #ifndef SERIALUI_SRC_INCLUDES_PLATFORM_LINUX_LINUXEXTINCLUDES_H_ 14 | #define SERIALUI_SRC_INCLUDES_PLATFORM_LINUX_LINUXEXTINCLUDES_H_ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | #include 29 | 30 | 31 | 32 | #endif /* SERIALUI_SRC_INCLUDES_PLATFORM_LINUX_LINUXEXTINCLUDES_H_ */ 33 | -------------------------------------------------------------------------------- /src/includes/menuitem/ItemList.h: -------------------------------------------------------------------------------- 1 | /* 2 | * List.h 3 | * 4 | * Created on: Apr 29, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | #ifndef SERIALUI_SRC_INCLUDES_MENUITEM_ITEMLIST_H_ 14 | #define SERIALUI_SRC_INCLUDES_MENUITEM_ITEMLIST_H_ 15 | 16 | #include "SubMenu.h" 17 | namespace SerialUI { 18 | namespace Menu { 19 | namespace Item { 20 | 21 | class List : public SubMenu { 22 | public: 23 | List(ID parentId, StaticString key, StaticString help); 24 | List(ID id, ID parentId, StaticString key, StaticString help); 25 | 26 | }; 27 | 28 | } /* namespace Item */ 29 | } /* namespace Menu */ 30 | } /* namespace SerialUI */ 31 | 32 | #endif /* SERIALUI_SRC_INCLUDES_MENUITEM_ITEMLIST_H_ */ 33 | -------------------------------------------------------------------------------- /src/includes/menuitem/requests/requests.h: -------------------------------------------------------------------------------- 1 | /* 2 | * requests.h 3 | * 4 | * Created on: May 26, 2018 5 | * Author: Pat Deegan 6 | * 7 | * requests is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUI_SRC_INCLUDES_MENUITEM_REQUESTS_REQUESTS_H_ 12 | #define SERIALUI_SRC_INCLUDES_MENUITEM_REQUESTS_REQUESTS_H_ 13 | 14 | 15 | #include "ItemReqBoolean.h" 16 | #include "ItemReqBoundedLong.h" 17 | #include "ItemReqCharacter.h" 18 | #include "ItemReqFloat.h" 19 | #include "ItemReqLong.h" 20 | #include "ItemReqOptions.h" 21 | #include "ItemReqString.h" 22 | #include "ItemReqUnsignedLong.h" 23 | #include "ItemReqDateTime.h" 24 | #include "ItemReqTime.h" 25 | #include "ItemReqEvent.h" 26 | #include "ItemReqPassphrase.h" 27 | #include "ItemReqColor.h" 28 | 29 | 30 | #endif /* SERIALUI_SRC_INCLUDES_MENUITEM_REQUESTS_REQUESTS_H_ */ 31 | -------------------------------------------------------------------------------- /src/includes/auth/AuthTypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AuthTypes.h 3 | * 4 | * Created on: Jun 6, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | #ifndef SERIALUI_SRC_INCLUDES_AUTH_AUTHTYPES_H_ 14 | #define SERIALUI_SRC_INCLUDES_AUTH_AUTHTYPES_H_ 15 | 16 | 17 | #include "../SerialUIPlatform.h" 18 | #include "../SerialUITypes.h" 19 | namespace SerialUI { 20 | namespace Auth { 21 | 22 | typedef DynamicString Passphrase; 23 | typedef DynamicString Challenge; 24 | typedef DynamicString ChallengeResponse; 25 | 26 | namespace Level { 27 | typedef enum ValueEnum { 28 | NoAccess= 0, 29 | Guest = 1, 30 | User = 2, 31 | Admin = 3 32 | } Value; 33 | 34 | } 35 | 36 | } 37 | } 38 | 39 | 40 | #endif /* SERIALUI_SRC_INCLUDES_AUTH_AUTHTYPES_H_ */ 41 | -------------------------------------------------------------------------------- /src/includes/auth/AuthStorage.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AuthStorage.h 3 | * 4 | * Created on: Jun 6, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | #ifndef SERIALUI_SRC_INCLUDES_AUTH_AUTHSTORAGE_H_ 14 | #define SERIALUI_SRC_INCLUDES_AUTH_AUTHSTORAGE_H_ 15 | #include "../SerialUIPlatform.h" 16 | #include "AuthTypes.h" 17 | 18 | namespace SerialUI { 19 | namespace Auth { 20 | 21 | class Storage { 22 | public: 23 | Storage(); 24 | virtual ~Storage(); 25 | virtual bool configured(Level::Value forLevel=Level::User) { return false;} 26 | virtual Passphrase passphrase(Level::Value forLevel) = 0; 27 | virtual bool setPassphrase(Passphrase pass, Level::Value forLevel) = 0; 28 | }; 29 | 30 | } /* namespace Auth */ 31 | } /* namespace SerialUI */ 32 | 33 | #endif /* SERIALUI_SRC_INCLUDES_AUTH_AUTHSTORAGE_H_ */ 34 | -------------------------------------------------------------------------------- /src/includes/menuitem/ItemCommand.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ItemCommand.h 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * ItemCommand is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUIV3_SRC_INCLUDES_MENUITEM_ITEMCOMMAND_H_ 12 | #define SERIALUIV3_SRC_INCLUDES_MENUITEM_ITEMCOMMAND_H_ 13 | 14 | #include "MenuItem.h" 15 | #include "../Menu.h" 16 | 17 | namespace SerialUI { 18 | namespace Menu { 19 | namespace Item { 20 | 21 | class Command : public Item { 22 | public: 23 | typedef CommandCallback Callback; 24 | Command(Callback cb, StaticString key, StaticString help); 25 | Command(ID id, Callback cb, StaticString key, StaticString help); 26 | 27 | virtual void call(Menu * callingMenu); 28 | private: 29 | Callback _cb; 30 | }; 31 | 32 | } /* namespace Item */ 33 | } /* namespace Menu */ 34 | } /* namespace SerialUI */ 35 | 36 | #endif /* SERIALUIV3_SRC_INCLUDES_MENUITEM_ITEMCOMMAND_H_ */ 37 | -------------------------------------------------------------------------------- /src/SUIPlatArduino.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SUIPlatArduino.cpp 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * SUIPlatArduino is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #include "includes/SerialUIPlatform.h" 12 | #include "includes/SerialUITypes.h" 13 | 14 | 15 | namespace SerialUI { 16 | 17 | size_t staticStringLength(StaticString aKey) { 18 | return SUI_PLATFORM_STATICSTRING_LENGTH(aKey); 19 | 20 | } 21 | bool staticStringMatch(StaticString aKey, DynamicString theTest, bool allowPartials) { 22 | 23 | size_t testLen = staticStringLength(aKey); 24 | size_t bLen = strlen(theTest); 25 | if (!allowPartials) { 26 | 27 | if (testLen != bLen) { 28 | return false; 29 | } 30 | } else if (bLen < testLen) { 31 | testLen = bLen; 32 | } 33 | TopLevelString k(aKey); 34 | 35 | 36 | return (strncmp(k.c_str(), theTest, testLen) == 0); 37 | 38 | } 39 | 40 | } /* namespace SerialUI */ 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/includes/settings/StateStorage.h: -------------------------------------------------------------------------------- 1 | /* 2 | * StateStorage.h 3 | * 4 | * Created on: May 1, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | #ifndef SERIALUI_SRC_INCLUDES_SETTINGS_STATESTORAGE_H_ 14 | #define SERIALUI_SRC_INCLUDES_SETTINGS_STATESTORAGE_H_ 15 | 16 | #include "../SerialUIPlatform.h" 17 | 18 | namespace SerialUI { 19 | namespace Settings { 20 | 21 | typedef char SerializedStateByte; 22 | typedef SerializedStateByte * SerializedState; 23 | class Storage { 24 | public: 25 | Storage() {} 26 | virtual ~Storage() {} 27 | 28 | virtual bool retrieve(SerializedState into, uint16_t maxlen) = 0; 29 | virtual bool save(SerializedState st) = 0; 30 | 31 | }; 32 | 33 | } /* namespace Settings */ 34 | } /* namespace SerialUI */ 35 | 36 | #endif /* SERIALUI_SRC_INCLUDES_SETTINGS_STATESTORAGE_H_ */ 37 | -------------------------------------------------------------------------------- /src/includes/comm/ChannelManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ChannelManager.h 3 | * 4 | * Created on: May 27, 2018 5 | * Author: Pat Deegan 6 | * 7 | * ChannelManager is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUI_SRC_INCLUDES_COMM_CHANNELMANAGER_H_ 12 | #define SERIALUI_SRC_INCLUDES_COMM_CHANNELMANAGER_H_ 13 | #include "../SerialUIPlatform.h" 14 | #include "../SerialUITypes.h" 15 | #include "CommChannel.h" 16 | namespace SerialUI { 17 | namespace Comm { 18 | 19 | class ChannelManager { 20 | public: 21 | static Channel * newChannelFor(Mode::Selection mode, SourceType * underlyingStream=NULL); 22 | static void releaseChannel(Channel * ch=NULL); 23 | 24 | inline static Channel * currentChannel() { return current_channel;} 25 | private: 26 | static Channel * current_channel; 27 | ChannelManager(); 28 | }; 29 | 30 | } /* namespace Comm */ 31 | } /* namespace SerialUI */ 32 | 33 | #endif /* SERIALUI_SRC_INCLUDES_COMM_CHANNELMANAGER_H_ */ 34 | -------------------------------------------------------------------------------- /src/TrackedVariable.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * TrackedVariable.cpp 3 | * 4 | * Created on: May 26, 2018 5 | * Author: Pat Deegan 6 | * 7 | * TrackedVariable is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #include "includes/tracked/TrackedVariable.h" 12 | 13 | 14 | namespace SerialUI { 15 | namespace Tracked { 16 | 17 | ID State::id_counter = 0; 18 | 19 | State::State() : _name(NULL), _hasChanged(true) { 20 | _id = id_counter++; 21 | 22 | } 23 | 24 | State::State(ID setId) : _id(setId), 25 | _name(NULL), 26 | _hasChanged(true) { 27 | 28 | if (setId >= id_counter) { 29 | id_counter = setId+1; 30 | } 31 | 32 | } 33 | 34 | 35 | State::State(StaticString nm) : _name(nm), _hasChanged(true) { 36 | _id = id_counter++; 37 | 38 | } 39 | State::State(StaticString nm, ID setId) :_id(setId), 40 | _name(nm), _hasChanged(true) { 41 | if (setId >= id_counter) { 42 | id_counter = setId+1; 43 | } 44 | 45 | } 46 | 47 | 48 | 49 | } 50 | } 51 | 52 | 53 | -------------------------------------------------------------------------------- /src/includes/menu/Tracking.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tracking.h 3 | * 4 | * Created on: May 26, 2018 5 | * Author: Pat Deegan 6 | * 7 | * Tracking is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUI_SRC_INCLUDES_MENU_TRACKING_H_ 12 | #define SERIALUI_SRC_INCLUDES_MENU_TRACKING_H_ 13 | 14 | #include "../SerialUIConfig.h" 15 | #include "../GrowableList.h" 16 | #include "../tracked/tracked.h" 17 | 18 | #ifndef SERIALUI_TRACKING_NUMITEMS_ATSTARTUP 19 | #define SERIALUI_TRACKING_NUMITEMS_ATSTARTUP SERIALUI_TRACKING_NUMITEMS_ATSTARTUP_DEFAULT 20 | #endif 21 | 22 | namespace SerialUI { 23 | namespace Menu { 24 | 25 | class Tracking : public GrowableList{ 26 | public: 27 | Tracking(uint8_t numItems=SERIALUI_TRACKING_NUMITEMS_ATSTARTUP); 28 | Tracked::State * itemByName(DynamicString aKey); 29 | }; 30 | 31 | } /* namespace Menu */ 32 | } /* namespace SerialUI */ 33 | 34 | #endif /* SERIALUI_SRC_INCLUDES_MENU_TRACKING_H_ */ 35 | -------------------------------------------------------------------------------- /src/ItemReqDateTime.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ItemReqDateTime.cpp 3 | * 4 | * Created on: Jun 2, 2018 5 | * Author: Pat Deegan 6 | * 7 | * ItemReqDateTime is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #include "includes/menuitem/requests/ItemReqDateTime.h" 12 | 13 | namespace SerialUI { 14 | namespace Menu { 15 | namespace Item { 16 | namespace Request { 17 | 18 | 19 | DateTime::DateTime(unsigned long int initVal, StaticString key, 20 | StaticString help, ValueChangedCallback vchng, 21 | ValidatorCallback validcb) : 22 | UnsignedLong(initVal, key, help, 23 | vchng, validcb) { 24 | 25 | setRequestType(Type::DateTime); 26 | } 27 | 28 | 29 | DateTime::DateTime(unsigned long int initVal, ValueChangedCallback vchng, 30 | ValidatorCallback validcb) : 31 | UnsignedLong(initVal, vchng, validcb) { 32 | setRequestType(Type::DateTime); 33 | } 34 | 35 | } /* namespace Request */ 36 | } /* namespace Item */ 37 | } /* namespace Menu */ 38 | } /* namespace SerialUI */ 39 | -------------------------------------------------------------------------------- /src/includes/menuitem/ItemText.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ItemText.h 3 | * 4 | * Created on: May 31, 2018 5 | * Author: Pat Deegan 6 | * 7 | * ItemText is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUI_SRC_INCLUDES_MENUITEM_ITEMTEXT_H_ 12 | #define SERIALUI_SRC_INCLUDES_MENUITEM_ITEMTEXT_H_ 13 | 14 | #include "../SerialUITypes.h" 15 | #include "MenuItem.h" 16 | 17 | namespace SerialUI { 18 | namespace Menu { 19 | namespace Item { 20 | 21 | class Text : public Item { 22 | public: 23 | Text(StaticString title, StaticString contents); 24 | Text(ID id, StaticString title, StaticString contents); 25 | 26 | inline StaticString title() { 27 | return this->key(); 28 | } 29 | 30 | inline StaticString contents() { 31 | return this->help(); 32 | } 33 | 34 | 35 | virtual void call(Menu * callingMenu) {} 36 | 37 | }; 38 | 39 | } /* namespace Item */ 40 | } /* namespace Menu */ 41 | } /* namespace SerialUI */ 42 | 43 | #endif /* SERIALUI_SRC_INCLUDES_MENUITEM_ITEMTEXT_H_ */ 44 | -------------------------------------------------------------------------------- /src/includes/platform/linux/LinuxBLESerial.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LinuxBLESerial.h 3 | * 4 | * Created on: Apr 27, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | #ifndef SERIALUI_SRC_INCLUDES_PLATFORM_LINUX_LINUXBLESERIAL_H_ 14 | #define SERIALUI_SRC_INCLUDES_PLATFORM_LINUX_LINUXBLESERIAL_H_ 15 | #include "LinuxStream.h" 16 | 17 | namespace SerialUI { 18 | 19 | class LinuxBLESerial : public Stream { 20 | public: 21 | LinuxBLESerial(); 22 | bool begin(uint32_t v) { return true;} 23 | virtual int available(); 24 | virtual int read(); 25 | virtual int peek(); 26 | virtual void flush(); 27 | virtual size_t write(uint8_t); 28 | virtual size_t write(const uint8_t *buffer, size_t size); 29 | }; 30 | 31 | 32 | extern LinuxBLESerial _linBLESerial; 33 | 34 | } /* namespace SerialUI */ 35 | 36 | #endif /* SERIALUI_SRC_INCLUDES_PLATFORM_LINUX_LINUXBLESERIAL_H_ */ 37 | -------------------------------------------------------------------------------- /src/includes/platform/linux/LinuxStorageFilesystem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LinuxStorageFilesystem.h 3 | * 4 | * Created on: May 3, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | #ifndef SERIALUI_SRC_INCLUDES_PLATFORM_LINUX_LINUXSTORAGEFILESYSTEM_H_ 14 | #define SERIALUI_SRC_INCLUDES_PLATFORM_LINUX_LINUXSTORAGEFILESYSTEM_H_ 15 | 16 | #include "../../settings/StateStorage.h" 17 | #include "LinuxExtIncludes.h" 18 | 19 | namespace SerialUI { 20 | namespace Settings { 21 | 22 | class StorageFilesystem : public Storage { 23 | public: 24 | StorageFilesystem(std::string filepath); 25 | virtual bool retrieve(SerializedState into, uint16_t maxlen); 26 | virtual bool save(SerializedState st); 27 | 28 | private: 29 | std::string filepath; 30 | }; 31 | 32 | } /* namespace Settings */ 33 | } /* namespace SerialUI */ 34 | 35 | #endif /* SERIALUI_SRC_INCLUDES_PLATFORM_LINUX_LINUXSTORAGEFILESYSTEM_H_ */ 36 | -------------------------------------------------------------------------------- /src/includes/auth/AuthSimple.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AuthSimple.h 3 | * 4 | * Created on: Jun 6, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | #ifndef SERIALUI_SRC_INCLUDES_AUTH_AUTHSIMPLE_H_ 14 | #define SERIALUI_SRC_INCLUDES_AUTH_AUTHSIMPLE_H_ 15 | 16 | #include "Authenticator.h" 17 | 18 | #ifdef SERIALUI_AUTHENTICATOR_ENABLE 19 | 20 | #include "AuthValidatorEquality.h" 21 | #include "AuthStorageStatic.h" 22 | 23 | namespace SerialUI { 24 | namespace Auth { 25 | 26 | class Simple : public Authenticator { 27 | public: 28 | Simple(Passphrase adminPass, Passphrase userPass=NULL, 29 | Passphrase guestPass=NULL); 30 | 31 | private: 32 | StorageStatic pass_store; 33 | ValidatorEquality eq_validator; 34 | }; 35 | 36 | } /* namespace Auth */ 37 | } /* namespace SerialUI */ 38 | 39 | 40 | #endif /* SERIALUI_AUTHENTICATOR_ENABLE */ 41 | 42 | #endif /* SERIALUI_SRC_INCLUDES_AUTH_AUTHSIMPLE_H_ */ 43 | -------------------------------------------------------------------------------- /src/includes/menuitem/requests/ItemReqDateTime.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ItemReqDateTime.h 3 | * 4 | * Created on: Jun 2, 2018 5 | * Author: Pat Deegan 6 | * 7 | * ItemReqDateTime is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUI_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQDATETIME_H_ 12 | #define SERIALUI_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQDATETIME_H_ 13 | 14 | #include "ItemReqUnsignedLong.h" 15 | namespace SerialUI { 16 | namespace Menu { 17 | namespace Item { 18 | namespace Request { 19 | 20 | class DateTime : public UnsignedLong { 21 | public: 22 | DateTime(unsigned long int initVal=0, ValueChangedCallback vchng=NULL, 23 | ValidatorCallback validcb=NULL); 24 | DateTime(unsigned long int initVal, StaticString key, 25 | StaticString help, ValueChangedCallback vchng=NULL, 26 | ValidatorCallback validcb=NULL); 27 | }; 28 | 29 | } /* namespace Request */ 30 | } /* namespace Item */ 31 | } /* namespace Menu */ 32 | } /* namespace SerialUI */ 33 | 34 | #endif /* SERIALUI_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQDATETIME_H_ */ 35 | -------------------------------------------------------------------------------- /src/ItemReqCharacter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ItemReqCharacter.cpp 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * ItemReqCharacter is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #include "includes/menuitem/requests/ItemReqCharacter.h" 12 | #include "includes/SUIGlobals.h" 13 | 14 | namespace SerialUI { 15 | namespace Menu { 16 | namespace Item { 17 | namespace Request { 18 | 19 | Character::Character(char initVal, StaticString key, 20 | StaticString help, ValueChangedCallback vchng, ValidatorCallback validcb): 21 | TypedRequest(initVal, key, help, vchng, validcb){ 22 | 23 | } 24 | 25 | Character::Character(char initVal, ValueChangedCallback vchng, ValidatorCallback validcb): 26 | TypedRequest(initVal, vchng, validcb){ 27 | 28 | } 29 | 30 | bool Character::getValue(Menu * callingMenu, char * v) { 31 | return Globals::commSource()->getCharFor(id(), v); 32 | } 33 | 34 | } /* namespace Request */ 35 | } /* namespace Item */ 36 | } /* namespace Menu */ 37 | } /* namespace SerialUI */ 38 | -------------------------------------------------------------------------------- /extras/INSTALL.txt: -------------------------------------------------------------------------------- 1 | SerialUI Installation 2 | 3 | SerialUI: Serial User Interface. 4 | Copyright (C) 2013-2019 Pat Deegan. All rights reserved. 5 | https://devicedruid.com 6 | https://inductive-kickback.com/projects/SerialUI/ 7 | 8 | 9 | If you're using the Arduino IDE and building for 10 | Arduino, the installation procedure is the same 11 | as for any library and is described fully at: 12 | 13 | http://arduino.cc/en/Guide/Libraries 14 | 15 | The short version is: SerialUI now supports imports into 16 | the set of libraries directly as a zip file. Simply 17 | download the SerialUI-x.x.x.zip file and then, from 18 | within the Arduino IDE, select 19 | 20 | Sketch -> Include Library -> Add .ZIP library 21 | 22 | and select the SerialUI file. 23 | 24 | 25 | Do have a look at the 26 | 27 | File -> Examples -> SerialUI -> SuperBlinker 28 | 29 | example, the README.txt and/or the SerialUI.h header 30 | file. 31 | 32 | For other platforms/dev environments, just include 33 | the contents of the SerialUI directory wherever 34 | appropriate ;-) 35 | 36 | Pat Deegan, psychogenic.com 37 | 38 | -------------------------------------------------------------------------------- /src/includes/auth/AuthValidator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AuthValidator.h 3 | * 4 | * Created on: Jun 6, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | #ifndef SERIALUI_SRC_INCLUDES_AUTH_AUTHVALIDATOR_H_ 14 | #define SERIALUI_SRC_INCLUDES_AUTH_AUTHVALIDATOR_H_ 15 | #include "AuthTypes.h" 16 | #include "AuthStorage.h" 17 | 18 | namespace SerialUI { 19 | namespace Auth { 20 | 21 | class Validator { 22 | public: 23 | Validator(Storage * storage); 24 | virtual ~Validator(); 25 | virtual Transmission::Type::Value communicationType() = 0; 26 | virtual Challenge challenge(Level::Value forLevel=Level::User) = 0; 27 | virtual Level::Value grantAccess(ChallengeResponse resp) = 0; 28 | 29 | virtual bool configured() { return auth_store->configured();} 30 | Storage * storage() { return auth_store;} 31 | private: 32 | Storage * auth_store; 33 | }; 34 | 35 | } /* namespace Auth */ 36 | } /* namespace SerialUI */ 37 | 38 | 39 | #endif /* SERIALUI_SRC_INCLUDES_AUTH_AUTHVALIDATOR_H_ */ 40 | -------------------------------------------------------------------------------- /src/includes/auth/AuthStoragePython.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AuthStoragePython.h 3 | * 4 | * Created on: Jun 7, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | #ifndef SERIALUI_SRC_INCLUDES_AUTH_AUTHSTORAGEPYTHON_H_ 14 | #define SERIALUI_SRC_INCLUDES_AUTH_AUTHSTORAGEPYTHON_H_ 15 | #include "AuthStorage.h" 16 | 17 | #if defined(SERIALUI_AUTHENTICATOR_ENABLE) and defined(SERIALUI_PYTHONMODULES_SUPPORT_ENABLE) 18 | 19 | namespace SerialUI { 20 | namespace Auth { 21 | 22 | class StoragePython : public Storage { 23 | public: 24 | StoragePython(); 25 | 26 | virtual bool configured(Level::Value forLevel=Level::User); 27 | virtual Passphrase passphrase(Level::Value forLevel); 28 | virtual bool setPassphrase(Passphrase pass, Level::Value forLevel); 29 | 30 | }; 31 | 32 | } /* namespace Auth */ 33 | } /* namespace SerialUI */ 34 | 35 | #endif /* SERIALUI_PYTHONMODULES_SUPPORT_ENABLE and SERIALUI_AUTHENTICATOR_ENABLE */ 36 | #endif /* SERIALUI_SRC_INCLUDES_AUTH_AUTHSTORAGEPYTHON_H_ */ 37 | -------------------------------------------------------------------------------- /src/includes/menuitem/requests/ItemReqCharacter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ItemReqCharacter.h 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * ItemReqCharacter is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUIV3_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQCHARACTER_H_ 12 | #define SERIALUIV3_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQCHARACTER_H_ 13 | 14 | #include "../ItemRequest.h" 15 | namespace SerialUI { 16 | namespace Menu { 17 | namespace Item { 18 | namespace Request { 19 | 20 | class Character : public TypedRequest{ 21 | public: 22 | Character(char initVal='a', 23 | ValueChangedCallback vchng=NULL, ValidatorCallback validcb=NULL); 24 | Character(char initVal, StaticString key=NULL, 25 | StaticString help=NULL, ValueChangedCallback vchng=NULL, 26 | ValidatorCallback validcb=NULL); 27 | 28 | virtual bool getValue(Menu * callingMenu, char * v); 29 | }; 30 | 31 | } /* namespace Request */ 32 | } /* namespace Item */ 33 | } /* namespace Menu */ 34 | } /* namespace SerialUI */ 35 | 36 | #endif /* SERIALUIV3_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQCHARACTER_H_ */ 37 | -------------------------------------------------------------------------------- /src/includes/auth/AuthValidatorEquality.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AuthValidatorEquality.h 3 | * 4 | * Created on: Jun 6, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | #ifndef SERIALUI_SRC_INCLUDES_AUTH_AUTHVALIDATOREQUALITY_H_ 14 | #define SERIALUI_SRC_INCLUDES_AUTH_AUTHVALIDATOREQUALITY_H_ 15 | #include "AuthValidator.h" 16 | 17 | #ifdef SERIALUI_AUTHENTICATOR_ENABLE 18 | 19 | namespace SerialUI { 20 | namespace Auth { 21 | 22 | class ValidatorEquality : public Validator { 23 | public: 24 | ValidatorEquality(Storage * storage); 25 | 26 | virtual Challenge challenge(Level::Value forLevel=Level::User) 27 | { return NULL; } 28 | virtual Level::Value grantAccess(ChallengeResponse resp); 29 | virtual Transmission::Type::Value communicationType() { 30 | return Transmission::Type::Plain; 31 | } 32 | }; 33 | 34 | } /* namespace Auth */ 35 | } /* namespace SerialUI */ 36 | 37 | 38 | #endif /* SERIALUI_AUTHENTICATOR_ENABLE */ 39 | 40 | #endif /* SERIALUI_SRC_INCLUDES_AUTH_AUTHVALIDATOREQUALITY_H_ */ 41 | -------------------------------------------------------------------------------- /src/includes/auth/AuthValidatorPython.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AuthValidatorPython.h 3 | * 4 | * Created on: Jun 7, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | #ifndef SERIALUI_SRC_INCLUDES_AUTH_AUTHVALIDATORPYTHON_H_ 14 | #define SERIALUI_SRC_INCLUDES_AUTH_AUTHVALIDATORPYTHON_H_ 15 | #include "AuthValidator.h" 16 | 17 | #if defined(SERIALUI_AUTHENTICATOR_ENABLE) and defined(SERIALUI_PYTHONMODULES_SUPPORT_ENABLE) 18 | 19 | namespace SerialUI { 20 | namespace Auth { 21 | 22 | class ValidatorPython : public Validator { 23 | public: 24 | ValidatorPython(Storage * storage); 25 | 26 | virtual Challenge challenge(Level::Value forLevel=Level::User); 27 | virtual Level::Value grantAccess(ChallengeResponse resp); 28 | virtual Transmission::Type::Value communicationType() ; 29 | }; 30 | 31 | } /* namespace Auth */ 32 | } /* namespace SerialUI */ 33 | 34 | #endif /* SERIALUI_PYTHONMODULES_SUPPORT_ENABLE and SERIALUI_AUTHENTICATOR_ENABLE */ 35 | 36 | #endif /* SERIALUI_SRC_INCLUDES_AUTH_AUTHVALIDATORPYTHON_H_ */ 37 | -------------------------------------------------------------------------------- /src/CommRequest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * CommRequest.cpp 3 | * 4 | * Created on: May 28, 2018 5 | * Author: Pat Deegan 6 | * 7 | * CommRequest is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #include "includes/comm/CommRequest.h" 12 | 13 | 14 | namespace SerialUI { 15 | namespace Comm { 16 | 17 | bool Request::trigger(Menu::Menu * fromMenu) { 18 | if (isForMenuItem()) { 19 | menuItem->call(fromMenu); 20 | return true; 21 | } 22 | 23 | if (! isForBuiltIn()) { 24 | return false; 25 | } 26 | 27 | return false; 28 | } 29 | 30 | 31 | void Request::setMenuItem(Menu::Item::Item * selectedItem) { 32 | menuItem = selectedItem; 33 | if (menuItem) { 34 | requestType = SerialUI::Request::Type::MenuItem; 35 | } else { 36 | 37 | requestType = SerialUI::Request::Type::INVALID; 38 | } 39 | } 40 | void Request::setBuiltIn(SerialUI::Request::BuiltIn::Selection sel) { 41 | builtIn = sel; 42 | if (sel == SerialUI::Request::BuiltIn::INVALID) { 43 | requestType = SerialUI::Request::Type::INVALID; 44 | } else { 45 | requestType = SerialUI::Request::Type::BuiltIn; 46 | } 47 | } 48 | 49 | } /* namespace Comm */ 50 | } /* namespace SerialUI */ 51 | -------------------------------------------------------------------------------- /src/ItemCommand.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ItemCommand.cpp 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * ItemCommand is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #include "includes/menuitem/ItemCommand.h" 12 | #include "includes/SUIGlobals.h" 13 | 14 | namespace SerialUI { 15 | namespace Menu { 16 | namespace Item { 17 | 18 | Command::Command(Callback cb, StaticString key, StaticString help) 19 | : Item(Type::Command, key, help), _cb(cb) { 20 | 21 | } 22 | 23 | Command::Command(ID id, Callback cb, StaticString key, StaticString help) 24 | : Item(id, Type::Command, key, help), _cb(cb) 25 | { 26 | 27 | } 28 | 29 | void Command::call(Menu * callingMenu) { 30 | SerialUI::Globals::state()->processingCommand(this); 31 | if (_cb) { 32 | _cb(); 33 | } 34 | 35 | 36 | #ifdef SERIALUI_PYTHONMODULES_SUPPORT_ENABLE 37 | Python::ExternalModule * pymod = Globals::pythonModule(); 38 | if (pymod) { 39 | pymod->trigger(this); 40 | } 41 | #endif /* SERIALUI_PYTHONMODULES_SUPPORT_ENABLE */ 42 | 43 | SerialUI::Globals::state()->setIdle(); 44 | } 45 | 46 | 47 | } /* namespace Item */ 48 | } /* namespace Menu */ 49 | } /* namespace SerialUI */ 50 | -------------------------------------------------------------------------------- /src/includes/auth/AuthStorageStatic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AuthStorageStatic.h 3 | * 4 | * Created on: Jun 6, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | #ifndef SERIALUI_SRC_INCLUDES_AUTH_AUTHSTORAGESTATIC_H_ 14 | #define SERIALUI_SRC_INCLUDES_AUTH_AUTHSTORAGESTATIC_H_ 15 | 16 | #include "Authenticator.h" 17 | #ifdef SERIALUI_AUTHENTICATOR_ENABLE 18 | 19 | namespace SerialUI { 20 | namespace Auth { 21 | 22 | class StorageStatic : public Storage { 23 | public: 24 | StorageStatic(Passphrase adminPass, Passphrase userPass, 25 | Passphrase guestPass=NULL); 26 | 27 | virtual bool configured(Level::Value forLevel=Level::User); 28 | 29 | virtual Passphrase passphrase(Level::Value forLevel) ; 30 | virtual bool setPassphrase(Passphrase pass, Level::Value forLevel); 31 | private: 32 | Passphrase stored_pass[4]; 33 | char * uconfiged_pass[4]; 34 | 35 | }; 36 | 37 | } /* namespace Auth */ 38 | } /* namespace SerialUI */ 39 | 40 | #endif /* SERIALUI_AUTHENTICATOR_ENABLE */ 41 | #endif /* SERIALUI_SRC_INCLUDES_AUTH_AUTHSTORAGESTATIC_H_ */ 42 | -------------------------------------------------------------------------------- /src/ItemDynamicText.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ItemDynamicText.cpp 3 | * 4 | * Created on: May 31, 2018 5 | * Author: Pat Deegan 6 | * 7 | * ItemDynamicText is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #include "includes/menuitem/ItemDynamicText.h" 12 | 13 | namespace SerialUI { 14 | namespace Menu { 15 | namespace Item { 16 | 17 | 18 | DynamicText::DynamicText(const TopLevelString& dynTitle, 19 | const TopLevelString& dynContent) 20 | : Item(Type::DynamicText, SUI_STR("_dt"), NULL), 21 | _title(dynTitle), 22 | _contents(dynContent) 23 | { 24 | } 25 | 26 | DynamicText::DynamicText(ID id, 27 | const TopLevelString& dynTitle, const TopLevelString& dynContent) 28 | : Item(id, Type::DynamicText, SUI_STR("_dt"), NULL), 29 | _title(dynTitle), 30 | _contents(dynContent) 31 | { 32 | } 33 | 34 | void DynamicText::setTitle(const TopLevelString& setTo) { 35 | _title = setTo; 36 | // TODO: FIXME notify upper layers?? 37 | } 38 | 39 | void DynamicText::setContents( 40 | const TopLevelString& setTo) { 41 | _contents = setTo; 42 | // TODO: FIXME notify upper layers?? 43 | } 44 | 45 | 46 | } /* namespace Item */ 47 | } /* namespace Menu */ 48 | } /* namespace SerialUI */ 49 | -------------------------------------------------------------------------------- /src/includes/settings/DeSerializerJson.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DeSerializerJson.h 3 | * 4 | * Created on: May 3, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | #ifndef SERIALUI_SRC_INCLUDES_SETTINGS_DESERIALIZERJSON_H_ 14 | #define SERIALUI_SRC_INCLUDES_SETTINGS_DESERIALIZERJSON_H_ 15 | 16 | 17 | #include "../SerialUIPlatform.h" 18 | 19 | #ifdef SERIALUI_SERIALIZER_JSON_ENABLE 20 | #include "SerializerJson.h" 21 | #include "DeSerializer.h" 22 | namespace SerialUI { 23 | namespace Settings { 24 | 25 | class DeSerializerJson : public DeSerializer { 26 | public: 27 | DeSerializerJson(Storage * store, uint16_t maxsize=256); 28 | 29 | protected: 30 | virtual bool deserializeFrom(SerializedState buf); 31 | 32 | private: 33 | bool deserializeObj(JsonObject obj); 34 | bool deserializeArray(JsonArray obj); 35 | bool deserializeVariant(JsonVariant obj); 36 | 37 | }; 38 | 39 | } /* namespace Settings */ 40 | } /* namespace SerialUI */ 41 | 42 | #endif /* SERIALUI_SERIALIZER_JSON_ENABLE */ 43 | 44 | 45 | #endif /* SERIALUI_SRC_INCLUDES_SETTINGS_DESERIALIZERJSON_H_ */ 46 | -------------------------------------------------------------------------------- /src/ItemReqFloat.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ItemReqFloat.cpp 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * ItemReqFloat is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | 12 | #include "includes/menuitem/requests/ItemReqFloat.h" 13 | #include "includes/SUIGlobals.h" 14 | 15 | 16 | namespace SerialUI { 17 | namespace Menu { 18 | namespace Item { 19 | namespace Request { 20 | 21 | Float::Float(float initVal, StaticString key, 22 | StaticString help, ValueChangedCallback vchng, ValidatorCallback validcb) : 23 | COUNTABLEREQCLASS_PARENT(Type::Float, float, Float)(initVal, key, help, vchng, validcb) 24 | { 25 | 26 | } 27 | 28 | Float::Float(float initVal, ValueChangedCallback vchng, ValidatorCallback validcb) : 29 | COUNTABLEREQCLASS_PARENT(Type::Float, float, Float)(initVal, vchng, validcb) 30 | { 31 | 32 | } 33 | 34 | 35 | bool Float::getValue(Menu * callingMenu, float * v) { 36 | return Globals::commSource()->getFloatFor(id(), v); 37 | } 38 | 39 | ITEMPYTHONOVERRIDE_VALIDATION(COUNTABLEREQCLASS_PARENT(Type::Float, float, Float), Float, float) 40 | 41 | 42 | } /* namespace Request */ 43 | } /* namespace Item */ 44 | } /* namespace Menu */ 45 | } /* namespace SerialUI */ 46 | -------------------------------------------------------------------------------- /src/ItemReqLong.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ItemReqLong.cpp 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * ItemReqLong is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #include "includes/menuitem/requests/ItemReqLong.h" 12 | #include "includes/SUIGlobals.h" 13 | 14 | namespace SerialUI { 15 | namespace Menu { 16 | namespace Item { 17 | namespace Request { 18 | 19 | 20 | Long::Long(long int initVal, StaticString key, 21 | StaticString help, ValueChangedCallback vchng, ValidatorCallback validcb) : 22 | CountableTypedRequest(initVal, key, help, vchng, validcb) 23 | { 24 | 25 | } 26 | Long::Long(long int initVal, ValueChangedCallback vchng, ValidatorCallback validcb) : 27 | CountableTypedRequest(initVal, vchng, validcb) 28 | { 29 | 30 | } 31 | bool Long::getValue(Menu * callingMenu, long int * v) { 32 | return Globals::commSource()->getLongIntFor(id(), v); 33 | } 34 | 35 | ITEMPYTHONOVERRIDE_VALIDATION(COUNTABLEREQCLASS_PARENT(Type::LongInt, long int, Long), 36 | Long, long int) 37 | 38 | 39 | 40 | } /* namespace Request */ 41 | } /* namespace Item */ 42 | } /* namespace Menu */ 43 | } /* namespace SerialUI */ 44 | -------------------------------------------------------------------------------- /src/includes/menuitem/trackedview/trackedviews.h: -------------------------------------------------------------------------------- 1 | /* 2 | * trackedviews.h 3 | * 4 | * Created on: Sep 27, 2018 5 | * Author: Pat Deegan 6 | * 7 | * trackedviews is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUI_SRC_INCLUDES_MENUITEM_TRACKEDVIEW_TRACKEDVIEWS_H_ 12 | #define SERIALUI_SRC_INCLUDES_MENUITEM_TRACKEDVIEW_TRACKEDVIEWS_H_ 13 | 14 | #include "../../SerialUITypes.h" 15 | #include "../ItemTrackedView.h" 16 | 17 | 18 | namespace SerialUI { 19 | namespace Menu { 20 | namespace Item { 21 | namespace View { 22 | 23 | typedef TrackedViewImpl BarChart; 24 | typedef TrackedViewImpl LineBasic; 25 | typedef TrackedViewImpl LineBoundaries; 26 | typedef TrackedViewImpl PieChart; 27 | typedef TrackedViewImpl CurrentValue; 28 | typedef TrackedViewImpl HistoryLog; 29 | 30 | } 31 | 32 | 33 | } /* namespace Item */ 34 | } /* namespace Menu */ 35 | } /* namespace SerialUI */ 36 | 37 | 38 | 39 | 40 | #endif /* SERIALUI_SRC_INCLUDES_MENUITEM_TRACKEDVIEW_TRACKEDVIEWS_H_ */ 41 | -------------------------------------------------------------------------------- /src/includes/strings/SUIStrings_en.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SUIStrings_en.h 3 | * 4 | * Created on: May 28, 2018 5 | * Author: Pat Deegan 6 | * 7 | * SUIStrings_en is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUI_SRC_INCLUDES_STRINGS_SUISTRINGS_EN_H_ 12 | #define SERIALUI_SRC_INCLUDES_STRINGS_SUISTRINGS_EN_H_ 13 | 14 | 15 | 16 | #define SUI_SERIALUI_TOP_MENU_NAME "TOP" 17 | 18 | #define SUI_SERIALUI_HELP_COMMAND "?" 19 | #define SUI_SERIALUI_UP_COMMAND ".." 20 | #define SUI_SERIALUI_EXIT_COMMAND "quit" 21 | #define SUI_SERIALUI_MODEPROG_COMMAND "m:pgm" 22 | #define SUI_SERIALUI_MODEUSER_COMMAND "m:usr" 23 | #define SUI_SERIALUI_KEEPALIVE_COMMAND "p:ng" 24 | 25 | 26 | 27 | 28 | 29 | 30 | // built-in commands 31 | #define SUI_SERIALUI_HELP_HELP "List available menu items" 32 | #define SUI_SERIALUI_UP_HELP "Move up to parent menu" 33 | #define SUI_SERIALUI_EXIT_HELP "Exit SerialUI" 34 | 35 | // help-related 36 | #define SUI_SERIALUI_HELP_HINT "Enter '?' for available options" 37 | #define SUI_SERIALUI_SUBMENU_HELP "Enter sub-menu" 38 | 39 | #define SUI_SERIALUI_HELP_TITLE_PREFIX "*** Help for: " 40 | 41 | 42 | 43 | #endif /* SERIALUI_SRC_INCLUDES_STRINGS_SUISTRINGS_EN_H_ */ 44 | -------------------------------------------------------------------------------- /src/includes/menuitem/requests/ItemReqFloat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ItemReqFloat.h 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * ItemReqFloat is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUIV3_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQFLOAT_H_ 12 | #define SERIALUIV3_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQFLOAT_H_ 13 | 14 | #include "../ItemRequest.h" 15 | 16 | 17 | namespace SerialUI { 18 | namespace Menu { 19 | namespace Item { 20 | namespace Request { 21 | 22 | class Float: public COUNTABLEREQCLASS_PARENT(Type::Float, float, Float) { 23 | public: 24 | Float(float initVal=0.0, ValueChangedCallback vchng=NULL, ValidatorCallback validcb=NULL); 25 | 26 | 27 | Float(float initVal, StaticString key=NULL, 28 | StaticString help=NULL, ValueChangedCallback vchng=NULL, ValidatorCallback validcb=NULL); 29 | 30 | 31 | virtual bool getValue(Menu * callingMenu, float * v); 32 | 33 | ITEMPYTHONOVERRIDE_VALIDATION_DECL(float); 34 | 35 | COUTABLEREQCLASS_USINGALLOPS(Type::Float, float, Float); 36 | 37 | }; 38 | 39 | } /* namespace Request */ 40 | } /* namespace Item */ 41 | } /* namespace Menu */ 42 | } /* namespace SerialUI */ 43 | 44 | #endif /* SERIALUIV3_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQFLOAT_H_ */ 45 | -------------------------------------------------------------------------------- /src/includes/menuitem/requests/ItemReqLong.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ItemReqLong.h 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * ItemReqLong is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUIV3_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQLONG_H_ 12 | #define SERIALUIV3_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQLONG_H_ 13 | 14 | #include "../ItemRequest.h" 15 | 16 | namespace SerialUI { 17 | namespace Menu { 18 | namespace Item { 19 | namespace Request { 20 | 21 | class Long : public COUNTABLEREQCLASS_PARENT(Type::LongInt, long int, Long){ 22 | public: 23 | Long(long int initVal, ValueChangedCallback vchng=NULL, ValidatorCallback validcb=NULL); 24 | 25 | 26 | Long(long int initVal=0, StaticString key=NULL, 27 | StaticString help=NULL, ValueChangedCallback vchng=NULL, ValidatorCallback validcb=NULL); 28 | 29 | 30 | virtual bool getValue(Menu * callingMenu, long int * v); 31 | 32 | 33 | ITEMPYTHONOVERRIDE_VALIDATION_DECL(long int); 34 | 35 | COUTABLEREQCLASS_USINGALLOPS(Type::LongInt, long int, Long); 36 | }; 37 | 38 | } /* namespace Request */ 39 | } /* namespace Item */ 40 | } /* namespace Menu */ 41 | } /* namespace SerialUI */ 42 | 43 | #endif /* SERIALUIV3_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQLONG_H_ */ 44 | -------------------------------------------------------------------------------- /src/ItemTrackedView.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ItemTrackedView.cpp 3 | * 4 | * Created on: Sep 27, 2018 5 | * Author: Pat Deegan 6 | * 7 | * ItemTrackedView is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #include "includes/menuitem/ItemTrackedView.h" 12 | 13 | 14 | namespace SerialUI { 15 | namespace Menu { 16 | namespace Item { 17 | 18 | 19 | TrackedView::TrackedView(Tracked::View::Type vType, StaticString key, StaticString help) : 20 | Item(Type::TrackedView, key, help), 21 | _viewType(vType), 22 | _num(0) 23 | { 24 | for (uint8_t i=0; i= SERIALUI_TRACKEDVIEW_MAXNUM_STATES) { 43 | return false; 44 | } 45 | trackedVars[_num++] = &st; 46 | return true; 47 | } 48 | 49 | 50 | 51 | 52 | 53 | } /* namespace Item */ 54 | } /* namespace Menu */ 55 | } /* namespace SerialUI */ 56 | -------------------------------------------------------------------------------- /src/ChannelManager.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ChannelManager.cpp 3 | * 4 | * Created on: May 27, 2018 5 | * Author: Pat Deegan 6 | * 7 | * ChannelManager is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #include "includes/comm/ChannelManager.h" 12 | #include "includes/comm/channels.h" 13 | 14 | 15 | namespace SerialUI { 16 | namespace Comm { 17 | 18 | Channel * ChannelManager::current_channel = NULL; 19 | 20 | ChannelManager::ChannelManager() { 21 | 22 | } 23 | 24 | 25 | Channel * ChannelManager::newChannelFor(Mode::Selection mode, SourceType * underlyingStream) { 26 | if (mode == Mode::User) { 27 | if (underlyingStream) { 28 | current_channel = new ChannelModeUser(mode, underlyingStream); 29 | } else { 30 | current_channel= new ChannelModeUser(mode); 31 | } 32 | } else { 33 | if (underlyingStream) { 34 | current_channel = new ChannelModeProg(mode, underlyingStream); 35 | } else { 36 | current_channel= new ChannelModeProg(mode); 37 | } 38 | } 39 | return current_channel; 40 | } 41 | 42 | void ChannelManager::releaseChannel(Channel * chn) { 43 | if (chn) { 44 | delete chn; 45 | } else if (current_channel) { 46 | delete current_channel; 47 | } 48 | current_channel= NULL; 49 | } 50 | 51 | } /* namespace Comm */ 52 | } /* namespace SerialUI */ 53 | -------------------------------------------------------------------------------- /src/includes/menuitem/ItemDynamicText.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ItemDynamicText.h 3 | * 4 | * Created on: May 31, 2018 5 | * Author: Pat Deegan 6 | * 7 | * ItemDynamicText is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUI_SRC_INCLUDES_MENUITEM_ITEMDYNAMICTEXT_H_ 12 | #define SERIALUI_SRC_INCLUDES_MENUITEM_ITEMDYNAMICTEXT_H_ 13 | 14 | #include "../SerialUITypes.h" 15 | #include "MenuItem.h" 16 | 17 | 18 | namespace SerialUI { 19 | namespace Menu { 20 | namespace Item { 21 | 22 | class DynamicText : public Item { 23 | public: 24 | DynamicText(const TopLevelString & dynTitle, const TopLevelString & dynContent=""); 25 | DynamicText(ID id, const TopLevelString & dynTitle, const TopLevelString & dynContent=""); 26 | 27 | inline const TopLevelString & title() { return _title;} 28 | void setTitle(const TopLevelString & setTo); 29 | 30 | inline const TopLevelString & contents() { return _contents;} 31 | void setContents(const TopLevelString & setTo); 32 | 33 | 34 | 35 | virtual void call(Menu * callingMenu) {} 36 | 37 | private: 38 | TopLevelString _title; 39 | TopLevelString _contents; 40 | 41 | }; 42 | 43 | } /* namespace Item */ 44 | } /* namespace Menu */ 45 | } /* namespace SerialUI */ 46 | 47 | #endif /* SERIALUI_SRC_INCLUDES_MENUITEM_ITEMDYNAMICTEXT_H_ */ 48 | -------------------------------------------------------------------------------- /src/includes/auth/Authenticator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Authenticator.h 3 | * 4 | * Created on: Jun 6, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | #ifndef SERIALUI_SRC_INCLUDES_AUTH_AUTHENTICATOR_H_ 14 | #define SERIALUI_SRC_INCLUDES_AUTH_AUTHENTICATOR_H_ 15 | 16 | 17 | #include "AuthValidator.h" 18 | 19 | #ifdef SERIALUI_AUTHENTICATOR_ENABLE 20 | 21 | namespace SerialUI { 22 | namespace Auth { 23 | 24 | class Authenticator { 25 | public: 26 | Authenticator(Validator * validator); 27 | 28 | bool configured(); 29 | bool setPassphrase(Passphrase pass, Level::Value forLevel); 30 | 31 | Transmission::Type::Value encoding(); 32 | Challenge challenge(Level::Value forLevel=Level::User) ; 33 | Level::Value grantAccess(ChallengeResponse resp) ; 34 | 35 | bool accessIsAtLeast(Level::Value lev); 36 | 37 | void clearAccess() { current_level = Level::NoAccess;} 38 | Level::Value accessLevel() { return current_level;} 39 | 40 | 41 | private: 42 | Validator * auth_validator; 43 | Level::Value current_level; 44 | }; 45 | 46 | } /* namespace Auth */ 47 | } /* namespace SerialUI */ 48 | 49 | #endif /* SERIALUI_AUTHENTICATOR_ENABLE */ 50 | 51 | #endif /* SERIALUI_SRC_INCLUDES_AUTH_AUTHENTICATOR_H_ */ 52 | -------------------------------------------------------------------------------- /src/SUIState.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * State.cpp 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * State is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #include "includes/SUIState.h" 12 | #include "includes/SUIGlobals.h" 13 | namespace SerialUI { 14 | 15 | State::State() : 16 | _currentActivity(Idle), _currentMenuId(0), _currentItemId(0), _currentMenu(NULL), 17 | _mode(Mode::User), 18 | _greetingMsg(NULL), 19 | _uid(NULL), 20 | _stateflags(0) 21 | { 22 | enterMenu(Globals::menuStructure()->topLevelMenu()); 23 | 24 | } 25 | 26 | void State::processingCommand(Menu::Item::Command * cmdItem) { 27 | _currentActivity = Command; 28 | _currentItemId = cmdItem->id(); 29 | } 30 | void State::gettingInput(Menu::Item::Request::Request * inputItem) { 31 | _currentActivity = InputRequest; 32 | _currentItemId = inputItem->id(); 33 | } 34 | 35 | void State::enterMenu(Menu::Item::SubMenu * sub) { 36 | _currentMenuId = sub->id(); 37 | _currentMenu = sub; 38 | } 39 | 40 | Menu::Item::Item * State::currentItem() { 41 | return Globals::menuStructure()->getItemById(_currentItemId); 42 | } 43 | 44 | 45 | void State::setGreeting(StaticString greets) 46 | { 47 | _greetingMsg = greets; 48 | } 49 | 50 | void State::setUID(StaticString u) { 51 | _uid = u; 52 | } 53 | 54 | 55 | 56 | 57 | } /* namespace SerialUI */ 58 | -------------------------------------------------------------------------------- /keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For TinyBrite 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | SerialUI KEYWORD1 9 | SUI KEYWORD1 10 | Menu KEYWORD1 11 | 12 | 13 | ####################################### 14 | # Methods and Functions (KEYWORD2) 15 | ####################################### 16 | SUI_DeclareString KEYWORD2 17 | topLevelMenu KEYWORD2 18 | addCommand KEYWORD2 19 | subMenu KEYWORD2 20 | name KEYWORD2 21 | setName KEYWORD2 22 | checkForUserOnce KEYWORD2 23 | checkForUser KEYWORD2 24 | userPresent KEYWORD2 25 | handleRequests KEYWORD2 26 | currentMenu KEYWORD2 27 | 28 | showName KEYWORD2 29 | showEnterDataPrompt KEYWORD2 30 | showPrompt KEYWORD2 31 | showEnterNumericDataPrompt KEYWORD2 32 | showEnterStreamPromptAndReceive KEYWORD2 33 | returnOK KEYWORD2 34 | returnError KEYWORD2 35 | returnMessage KEYWORD2 36 | 37 | maxIdleMs KEYWORD2 38 | setMaxIdleMs KEYWORD2 39 | 40 | setReadTerminator KEYWORD2 41 | readTerminator KEYWORD2 42 | 43 | echoCommands KEYWORD2 44 | setEchoCommands KEYWORD2 45 | setCurrentMenu KEYWORD2 46 | ####################################### 47 | # Instances (KEYWORD2) 48 | ####################################### 49 | 50 | 51 | ####################################### 52 | # Constants (LITERAL1) 53 | ####################################### 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/includes/comm/CommSource.h: -------------------------------------------------------------------------------- 1 | /* 2 | * CommSource.h 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * CommSource is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUIV3_SRC_INCLUDES_COMM_COMMSOURCE_H_ 12 | #define SERIALUIV3_SRC_INCLUDES_COMM_COMMSOURCE_H_ 13 | #include "../SerialUIExtIncludes.h" 14 | #include "../SerialUITypes.h" 15 | #include "../SerialUIPlatform.h" 16 | #include "CommRequest.h" 17 | 18 | 19 | namespace SerialUI { 20 | namespace Comm { 21 | 22 | class Source : public SourceBase { 23 | public: 24 | Source(); 25 | virtual ~Source() {} 26 | using SourceBase::print; 27 | using SourceBase::println; 28 | // virtual int available() = 0; 29 | virtual void poll() = 0; 30 | virtual bool getBoolFor(Menu::Item::ID mid, bool * into) = 0; 31 | virtual bool getCharFor(Menu::Item::ID mid, char * into) = 0; 32 | virtual bool getLongIntFor(Menu::Item::ID mid, long int * into) = 0; 33 | virtual bool getLongUIntFor(Menu::Item::ID mid, unsigned long int * into) = 0; 34 | virtual bool getFloatFor(Menu::Item::ID mid, float * into) = 0; 35 | virtual bool getStringFor(Menu::Item::ID mid, uint8_t maxLength, ::String * into) = 0; 36 | 37 | virtual bool getNextRequest(Menu::Item::ID inMenu, Request * into) = 0; 38 | }; 39 | 40 | } /* namespace Comm */ 41 | } /* namespace SerialUI */ 42 | 43 | #endif /* SERIALUIV3_SRC_INCLUDES_COMM_COMMSOURCE_H_ */ 44 | -------------------------------------------------------------------------------- /src/LinuxStorageFilesystem.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * LinuxStorageFilesystem.cpp 3 | * 4 | * Created on: May 3, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | #include "includes/SerialUIPlatform.h" 14 | 15 | #ifdef SERIALUI_PLATFORM_LINUX 16 | 17 | #include "includes/platform/linux/LinuxStorageFilesystem.h" 18 | 19 | namespace SerialUI { 20 | namespace Settings { 21 | 22 | StorageFilesystem::StorageFilesystem(std::string fspath) : 23 | filepath(fspath) { 24 | 25 | } 26 | 27 | bool StorageFilesystem::retrieve(SerializedState into, uint16_t maxlen) { 28 | std::ifstream fileStream(filepath); 29 | if (! fileStream) { 30 | return false; 31 | } 32 | 33 | std::string content( (std::istreambuf_iterator(fileStream) ), 34 | (std::istreambuf_iterator() ) ); 35 | 36 | if (content.size() < maxlen) { 37 | maxlen = content.size(); 38 | } 39 | strncpy(into, content.c_str(), maxlen); 40 | return true; 41 | 42 | } 43 | bool StorageFilesystem::save(SerializedState st) { 44 | std::ofstream outStream(filepath); 45 | if (! outStream ) { 46 | return false; 47 | } 48 | outStream << st; 49 | outStream.close(); 50 | return true; 51 | 52 | } 53 | 54 | } /* namespace Settings */ 55 | } /* namespace SerialUI */ 56 | 57 | #endif /* SERIALUI_PLATFORM_LINUX */ 58 | -------------------------------------------------------------------------------- /src/ItemReqUnsignedLong.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ItemReqUnsignedLong.cpp 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * ItemReqUnsignedLong is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #include "includes/menuitem/requests/ItemReqUnsignedLong.h" 12 | #include "includes/SUIGlobals.h" 13 | 14 | namespace SerialUI { 15 | namespace Menu { 16 | namespace Item { 17 | namespace Request { 18 | 19 | UnsignedLong::UnsignedLong(unsigned long int initVal, StaticString key, 20 | StaticString help, ValueChangedCallback vchng, 21 | ValidatorCallback validcb) : 22 | COUNTABLEREQCLASS_PARENT(Type::UnsignedLongInt, unsigned long int, UnsignedLong)(initVal, key, help, 23 | vchng, validcb) { 24 | 25 | 26 | } 27 | 28 | 29 | UnsignedLong::UnsignedLong(unsigned long int initVal, ValueChangedCallback vchng, 30 | ValidatorCallback validcb) : 31 | COUNTABLEREQCLASS_PARENT(Type::UnsignedLongInt, unsigned long int, UnsignedLong)(initVal, vchng, validcb) { 32 | 33 | } 34 | 35 | bool UnsignedLong::getValue(Menu * callingMenu, unsigned long int * v) { 36 | return Globals::commSource()->getLongUIntFor(id(), v); 37 | } 38 | 39 | 40 | ITEMPYTHONOVERRIDE_VALIDATION(COUNTABLEREQCLASS_PARENT(Type::UnsignedLongInt, unsigned long int, UnsignedLong), 41 | UnsignedLong, unsigned long int); 42 | 43 | } /* namespace Request */ 44 | } /* namespace Item */ 45 | } /* namespace Menu */ 46 | } /* namespace SerialUI */ 47 | -------------------------------------------------------------------------------- /src/includes/menuitem/requests/ItemReqUnsignedLong.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ItemReqUnsignedLong.h 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * ItemReqUnsignedLong is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUIV3_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQUNSIGNEDLONG_H_ 12 | #define SERIALUIV3_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQUNSIGNEDLONG_H_ 13 | 14 | #include "../ItemRequest.h" 15 | 16 | namespace SerialUI { 17 | namespace Menu { 18 | namespace Item { 19 | namespace Request { 20 | 21 | class UnsignedLong : public 22 | COUNTABLEREQCLASS_PARENT(Type::UnsignedLongInt, unsigned long int, UnsignedLong) { 23 | public: 24 | UnsignedLong(unsigned long int initVal=0, ValueChangedCallback vchng=NULL, 25 | ValidatorCallback validcb=NULL); 26 | 27 | 28 | UnsignedLong(unsigned long int initVal, StaticString key, 29 | StaticString help, ValueChangedCallback vchng=NULL, 30 | ValidatorCallback validcb=NULL); 31 | 32 | 33 | virtual bool getValue(Menu * callingMenu, unsigned long int * v); 34 | 35 | 36 | ITEMPYTHONOVERRIDE_VALIDATION_DECL(unsigned long int); 37 | COUTABLEREQCLASS_USINGALLOPS(Type::UnsignedLongInt, unsigned long int, UnsignedLong); 38 | 39 | 40 | }; 41 | 42 | } /* namespace Request */ 43 | } /* namespace Item */ 44 | } /* namespace Menu */ 45 | } /* namespace SerialUI */ 46 | 47 | #endif /* SERIALUIV3_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQUNSIGNEDLONG_H_ */ 48 | -------------------------------------------------------------------------------- /src/Authenticator.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Authenticator.cpp 3 | * 4 | * Created on: Jun 6, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | #include "includes/auth/Authenticator.h" 14 | 15 | #ifdef SERIALUI_AUTHENTICATOR_ENABLE 16 | 17 | namespace SerialUI { 18 | namespace Auth { 19 | 20 | Authenticator::Authenticator(Validator * validator) : 21 | auth_validator(validator), 22 | current_level(Level::NoAccess) 23 | { 24 | 25 | } 26 | 27 | 28 | bool Authenticator::configured() { return auth_validator->configured();} 29 | bool Authenticator::setPassphrase(Passphrase pass, Level::Value forLevel) { 30 | return auth_validator->storage()->setPassphrase(pass, forLevel); 31 | } 32 | 33 | Challenge Authenticator::challenge(Level::Value forLevel) { 34 | return auth_validator->challenge(forLevel); 35 | } 36 | Level::Value Authenticator::grantAccess(ChallengeResponse resp) { 37 | current_level = auth_validator->grantAccess(resp); 38 | return current_level; 39 | } 40 | 41 | bool Authenticator::accessIsAtLeast(Level::Value lev) { 42 | return ((uint8_t)current_level >= lev); 43 | 44 | } 45 | 46 | Transmission::Type::Value Authenticator::encoding() { 47 | return auth_validator->communicationType(); 48 | } 49 | 50 | 51 | } /* namespace Auth */ 52 | } /* namespace SerialUI */ 53 | 54 | #endif /* SERIALUI_AUTHENTICATOR_ENABLE */ 55 | -------------------------------------------------------------------------------- /src/includes/menuitem/requests/externalPythonValidation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * externalPythonValidation.h 3 | * 4 | * Created on: Jun 10, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | #ifndef SERIALUI_SRC_INCLUDES_MENUITEM_REQUESTS_EXTERNALPYTHONVALIDATION_H_ 14 | #define SERIALUI_SRC_INCLUDES_MENUITEM_REQUESTS_EXTERNALPYTHONVALIDATION_H_ 15 | #include "../../SerialUIPlatform.h" 16 | 17 | #ifdef SERIALUI_PYTHONMODULES_SUPPORT_ENABLE 18 | 19 | #define ITEMPYTHONOVERRIDE_VALIDATION_DECL(thistype) \ 20 | /* override to support python validation */ \ 21 | virtual bool externalValidation(thistype & v) 22 | 23 | #define ITEMPYTHONOVERRIDE_VALIDATION(parentclass, thisclass, thistype) \ 24 | bool thisclass::externalValidation(thistype & v) { \ 25 | if (! this->parentclass::externalValidation(v)) {\ 26 | return false;\ 27 | }\ 28 | Python::ExternalModule * pymod = Globals::pythonModule();\ 29 | if (pymod && !pymod->isValidTrigger(this, v)) {\ 30 | return false;\ 31 | }\ 32 | return true;\ 33 | } 34 | 35 | #else 36 | 37 | 38 | #define ITEMPYTHONOVERRIDE_VALIDATION_DECL(thistype) 39 | 40 | #define ITEMPYTHONOVERRIDE_VALIDATION(parentclass, thisclass, thistype) 41 | 42 | #endif /* SERIALUI_PYTHONMODULES_SUPPORT_ENABLE */ 43 | 44 | 45 | 46 | #endif /* SERIALUI_SRC_INCLUDES_MENUITEM_REQUESTS_EXTERNALPYTHONVALIDATION_H_ */ 47 | -------------------------------------------------------------------------------- /src/includes/platform/nrf52/NRF52BLESerial.h: -------------------------------------------------------------------------------- 1 | /* 2 | * NRF52BLESerial.h 3 | * 4 | * Created on: May 12, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | #ifndef SERIALUI_SRC_INCLUDES_PLATFORM_NRF52_NRF52BLESERIAL_H_ 14 | #define SERIALUI_SRC_INCLUDES_PLATFORM_NRF52_NRF52BLESERIAL_H_ 15 | 16 | #include "includes/SerialUIExtIncludes.h" 17 | #include "includes/platform/nrf52/BLESerial.h" 18 | 19 | #include "includes/RingBuffer.h" 20 | 21 | namespace SerialUI { 22 | 23 | class NRF52BLESerial : public Stream { 24 | public: 25 | NRF52BLESerial(); 26 | 27 | void begin(...); 28 | void poll(); 29 | void end(); 30 | void setLocalName(const char * nm); 31 | 32 | 33 | virtual int available(void); 34 | virtual int peek(void); 35 | virtual int read(void); 36 | virtual void flush(void); 37 | virtual size_t write(uint8_t byte); 38 | using Print::write; 39 | virtual operator bool(); 40 | 41 | private: 42 | SUIBLESerial _bleser; 43 | RingBuffer rx_buf; 44 | RingBuffer tx_buf; 45 | void fillRXFromBLESerial(); 46 | uint32_t last_fill_ms; 47 | uint32_t last_flush_ms; 48 | 49 | 50 | 51 | }; 52 | 53 | 54 | } /* namespace SerialUI */ 55 | 56 | 57 | extern SerialUI::NRF52BLESerial SUIBLESerialDev; 58 | 59 | #endif /* SERIALUI_SRC_INCLUDES_PLATFORM_NRF52_NRF52BLESERIAL_H_ */ 60 | -------------------------------------------------------------------------------- /src/MenuItem.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MenuItem.cpp 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * MenuItem is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #include "includes/menuitem/MenuItem.h" 12 | #include "includes/SUIGlobals.h" 13 | #include "includes/Menu.h" 14 | 15 | namespace SerialUI { 16 | namespace Menu { 17 | namespace Item { 18 | ID Item::id_counter = 2; 19 | 20 | 21 | Item::Item(Type::Value itemType) : 22 | _parentId(0), _type(itemType), _key(NULL), _help(NULL) { 23 | 24 | _id = id_counter++; 25 | } 26 | Item::Item(Type::Value itemType, StaticString key, StaticString help) : 27 | _parentId(0), _type(itemType), _key(key), _help(help) 28 | { 29 | _id = id_counter++; 30 | } 31 | 32 | 33 | Item::Item(ID id, Type::Value itemType, StaticString key, StaticString help) : 34 | _id(id), _parentId(0), _type(itemType), _key(key), _help(help) 35 | { 36 | if (id_counter <= _id) { 37 | id_counter = _id+1; 38 | } 39 | } 40 | 41 | Item * Item::parent() { 42 | return Globals::menuStructure()->itemById(parentId()); 43 | } 44 | StaticStringLength Item::stringLength(StaticString str) { 45 | if (! str) { 46 | return 0; 47 | } 48 | return SUI_PLATFORM_STATICSTRING_LENGTH(str); 49 | } 50 | int8_t Item::positionInParent() { 51 | if (! parentId()) { 52 | return -1; 53 | } 54 | return Globals::menuStructure()->indexForItemWithParent(parentId(), id()); 55 | } 56 | 57 | } /* namespace Item */ 58 | } /* namespace Menu */ 59 | } /* namespace SerialUI */ 60 | 61 | -------------------------------------------------------------------------------- /src/includes/menuitem/requests/ItemReqString.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ItemReqString.h 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * ItemReqString is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUIV3_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQSTRING_H_ 12 | #define SERIALUIV3_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQSTRING_H_ 13 | 14 | #include "../ItemRequest.h" 15 | namespace SerialUI { 16 | namespace Menu { 17 | namespace Item { 18 | namespace Request { 19 | 20 | typedef TypedRequest ReqStringBase; 21 | 22 | 23 | class String : public ReqStringBase { 24 | public: 25 | 26 | String(uint8_t maxlen, ValueChangedCallback vchng=NULL, 27 | ValidatorCallback validcb=NULL); 28 | String( 29 | StaticString key, 30 | StaticString help, uint8_t maxlen, 31 | ValueChangedCallback vchng=NULL, 32 | ValidatorCallback validcb=NULL); 33 | String(TopLevelString initVal, 34 | StaticString key, 35 | StaticString help, uint8_t maxlen, 36 | ValueChangedCallback vchng=NULL, 37 | ValidatorCallback validcb=NULL); 38 | 39 | 40 | uint8_t maximumLength() { return _maxLen;} 41 | virtual bool getValue(Menu * callingMenu, TopLevelString * v); 42 | 43 | 44 | ITEMPYTHONOVERRIDE_VALIDATION_DECL(TopLevelString); 45 | 46 | private: 47 | uint8_t _maxLen; 48 | }; 49 | 50 | } /* namespace Request */ 51 | } /* namespace Item */ 52 | } /* namespace Menu */ 53 | } /* namespace SerialUI */ 54 | 55 | #endif /* SERIALUIV3_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQSTRING_H_ */ 56 | -------------------------------------------------------------------------------- /src/includes/python/pyhelper.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SUI_PYHELPER_HPP 2 | #define SUI_PYHELPER_HPP 3 | #pragma once 4 | 5 | #include 6 | 7 | PyObject* PyInit_SerialUIModule(void); 8 | 9 | class CPyInstance 10 | { 11 | public: 12 | CPyInstance() 13 | { 14 | PyImport_AppendInittab("SerialUI", &PyInit_SerialUIModule); 15 | 16 | Py_Initialize(); 17 | 18 | // DONT: PyEval_InitThreads(); 19 | } 20 | 21 | ~CPyInstance() 22 | { 23 | Py_Finalize(); 24 | } 25 | }; 26 | 27 | 28 | class CPyObject 29 | { 30 | private: 31 | PyObject *p; 32 | public: 33 | CPyObject() : p(NULL) 34 | {} 35 | 36 | CPyObject(PyObject* _p) : p(_p) 37 | {} 38 | 39 | 40 | ~CPyObject() 41 | { 42 | Release(); 43 | } 44 | 45 | PyObject* getObject() 46 | { 47 | return p; 48 | } 49 | 50 | PyObject* setObject(PyObject* _p) 51 | { 52 | return (p=_p); 53 | } 54 | 55 | PyObject* AddRef() 56 | { 57 | if(p) 58 | { 59 | Py_INCREF(p); 60 | } 61 | return p; 62 | } 63 | 64 | void Release() 65 | { 66 | if(p) 67 | { 68 | Py_DECREF(p); 69 | } 70 | 71 | p= NULL; 72 | } 73 | 74 | PyObject* operator ->() 75 | { 76 | return p; 77 | } 78 | 79 | bool is() 80 | { 81 | return p ? true : false; 82 | } 83 | 84 | operator PyObject*() 85 | { 86 | return p; 87 | } 88 | 89 | PyObject* operator = (PyObject* pp) 90 | { 91 | p = pp; 92 | return p; 93 | } 94 | 95 | operator bool() 96 | { 97 | return p ? true : false; 98 | } 99 | }; 100 | 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /src/includes/settings/DeSerializer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DeSerializer.h 3 | * 4 | * Created on: May 3, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | #ifndef SERIALUI_SRC_INCLUDES_SETTINGS_DESERIALIZER_H_ 14 | #define SERIALUI_SRC_INCLUDES_SETTINGS_DESERIALIZER_H_ 15 | 16 | 17 | #include "../menuitem/items.h" 18 | #include "StateStorage.h" 19 | 20 | 21 | namespace SerialUI { 22 | namespace Settings { 23 | 24 | class DeSerializer { 25 | public: 26 | DeSerializer(Storage * store, uint16_t maxsize) ; 27 | virtual ~DeSerializer() {} 28 | 29 | bool restore(); 30 | 31 | protected: 32 | uint16_t maxSize() { return max_serstate_len;} 33 | 34 | virtual bool deserializeFrom(SerializedState buf) = 0; 35 | 36 | bool setValue(Menu::Item::Request::Request * req, bool val); 37 | bool setValue(Menu::Item::Request::Request * req, unsigned long int val); 38 | bool setValue(Menu::Item::Request::Request * req, long int val); 39 | bool setValue(Menu::Item::Request::Request * req, float val); 40 | bool setValue(Menu::Item::Request::Request * req, char val); 41 | bool setValue(Menu::Item::Request::Request * req, const char * val); 42 | 43 | 44 | 45 | private: 46 | Storage * _storage; 47 | uint16_t max_serstate_len; 48 | 49 | }; 50 | 51 | 52 | } /* namespace Settings */ 53 | } /* namespace SerialUI */ 54 | 55 | 56 | 57 | 58 | #endif /* SERIALUI_SRC_INCLUDES_SETTINGS_DESERIALIZER_H_ */ 59 | -------------------------------------------------------------------------------- /src/includes/SUIGlobals.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SUIGlobals.h 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * SUIGlobals is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUIV3_SRC_INCLUDES_SUIGLOBALS_H_ 12 | #define SERIALUIV3_SRC_INCLUDES_SUIGLOBALS_H_ 13 | 14 | #include "SerialUIPlatform.h" 15 | #include "SUIState.h" 16 | #include "comm/CommSource.h" 17 | #include "menu/MenuStructure.h" 18 | #include "menu/Tracking.h" 19 | #include "comm/CommChannel.h" 20 | 21 | #ifdef SERIALUI_AUTHENTICATOR_ENABLE 22 | #include "auth/Authenticator.h" 23 | #endif 24 | 25 | #ifdef SERIALUI_PYTHONMODULES_SUPPORT_ENABLE 26 | #include "python/ExternalModule.h" 27 | #endif 28 | 29 | namespace SerialUI { 30 | 31 | class Globals { 32 | public: 33 | 34 | static State * state(); 35 | static Comm::Source * commSource(); 36 | static Comm::Channel * commChannel(); 37 | static Menu::Structure * menuStructure(); 38 | static Menu::Tracking * trackedStates(); 39 | 40 | #ifdef SERIALUI_PYTHONMODULES_SUPPORT_ENABLE 41 | static Python::ExternalModule * pythonModule(); 42 | static bool setPythonModule(Python::ExternalModule * mod); 43 | #endif /* SERIALUI_PYTHONMODULES_SUPPORT_ENABLE */ 44 | 45 | #ifdef SERIALUI_AUTHENTICATOR_ENABLE 46 | static Auth::Authenticator * authenticator(); 47 | static void setAuthenticator(Auth::Authenticator* auth); 48 | #endif /* SERIALUI_AUTHENTICATOR_ENABLE */ 49 | 50 | private: 51 | Globals(); 52 | 53 | 54 | }; 55 | 56 | } /* namespace SerialUI */ 57 | 58 | #endif /* SERIALUIV3_SRC_INCLUDES_SUIGLOBALS_H_ */ 59 | -------------------------------------------------------------------------------- /src/ItemReqString.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ItemReqString.cpp 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * ItemReqString is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | #include "includes/menuitem/requests/ItemReqString.h" 11 | #include "includes/SUIGlobals.h" 12 | 13 | namespace SerialUI { 14 | namespace Menu { 15 | namespace Item { 16 | namespace Request { 17 | 18 | String::String(TopLevelString initVal, 19 | StaticString key, 20 | StaticString help, uint8_t maxlen, 21 | ValueChangedCallback vchng, 22 | ValidatorCallback validcb) : 23 | ReqStringBase(initVal, key, help, 24 | vchng, validcb), 25 | _maxLen(maxlen) 26 | { 27 | 28 | } 29 | 30 | 31 | String::String(uint8_t maxlen, 32 | ValueChangedCallback vchng, 33 | ValidatorCallback validcb) : 34 | ReqStringBase("", vchng, validcb), 35 | _maxLen(maxlen) 36 | { 37 | 38 | } 39 | 40 | String::String( 41 | StaticString key, 42 | StaticString help, uint8_t maxlen, 43 | ValueChangedCallback vchng, 44 | ValidatorCallback validcb) : 45 | ReqStringBase("", key, help, 46 | vchng, validcb), 47 | _maxLen(maxlen) 48 | { 49 | 50 | } 51 | bool String::getValue(Menu * callingMenu, TopLevelString * v) { 52 | if (Globals::commSource()->getStringFor(id(), _maxLen, v)) 53 | { 54 | v->trim(); 55 | return true; 56 | } 57 | return false; 58 | } 59 | 60 | 61 | ITEMPYTHONOVERRIDE_VALIDATION(ReqStringBase, String, TopLevelString) 62 | 63 | 64 | 65 | } /* namespace Request */ 66 | } /* namespace Item */ 67 | } /* namespace Menu */ 68 | } /* namespace SerialUI */ 69 | -------------------------------------------------------------------------------- /src/LinuxBLESerial.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * LinuxBLESerial.cpp 3 | * 4 | * Created on: Apr 27, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | #include "includes/SerialUIPlatform.h" 14 | 15 | #ifdef SERIALUI_PLATFORM_LINUX 16 | 17 | #include "includes/platform/linux/LinuxBLESerial.h" 18 | 19 | namespace SerialUI { 20 | LinuxBLESerial _linBLESerial; 21 | 22 | LinuxBLESerial::LinuxBLESerial() { 23 | 24 | } 25 | 26 | 27 | int LinuxBLESerial::available() { 28 | return rx_buffer.getOccupied(); 29 | } 30 | int LinuxBLESerial::read() { 31 | uint8_t nextChar; 32 | if (! rx_buffer.getOccupied()) { 33 | return -1; 34 | } 35 | rx_buffer.readNext(&nextChar); 36 | return nextChar; 37 | } 38 | int LinuxBLESerial::peek() { 39 | uint8_t nextChar; 40 | if (! rx_buffer.getOccupied()) { 41 | return -1; 42 | } 43 | rx_buffer.peekNext(&nextChar); 44 | return nextChar; 45 | 46 | } 47 | void LinuxBLESerial::flush() { 48 | 49 | } 50 | size_t LinuxBLESerial::write(uint8_t c) { 51 | if (! tx_buffer.getFree()) { 52 | return 0; 53 | } 54 | tx_buffer.write(&c, 1); 55 | return 1; 56 | } 57 | size_t LinuxBLESerial::write(const uint8_t *buffer, size_t size) { 58 | size_t spaceLeft = tx_buffer.getFree(); 59 | if (! spaceLeft) { 60 | return 0; 61 | } 62 | if (size > spaceLeft) { 63 | size = spaceLeft; 64 | } 65 | return tx_buffer.write(buffer, size); 66 | 67 | } 68 | 69 | } /* namespace SerialUI */ 70 | 71 | #endif /* SERIALUI_PLATFORM_LINUX */ 72 | -------------------------------------------------------------------------------- /src/ItemReqTime.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ItemReqTime.cpp 3 | * 4 | * Created on: Jun 2, 2018 5 | * Author: Pat Deegan 6 | * 7 | * ItemReqTime is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #include "includes/menuitem/requests/ItemReqTime.h" 12 | 13 | namespace SerialUI { 14 | namespace Menu { 15 | namespace Item { 16 | namespace Request { 17 | 18 | 19 | Time::Time(uint8_t hour, uint8_t minute, uint8_t second, 20 | StaticString key, 21 | StaticString help, 22 | ValueChangedCallback vchng, 23 | ValidatorCallback validcb) : 24 | UnsignedLong(0, key, help, vchng, validcb) { 25 | 26 | setRequestType(Type::Time); 27 | setValue(toValue(TimeElements(hour, minute, second))); 28 | } 29 | 30 | 31 | Time::Time(unsigned long int initVal, StaticString key, 32 | StaticString help, ValueChangedCallback vchng, 33 | ValidatorCallback validcb) : 34 | UnsignedLong(initVal, key, help, 35 | vchng, validcb) { 36 | 37 | setRequestType(Type::Time); 38 | } 39 | 40 | 41 | Time::Time(unsigned long int initVal, ValueChangedCallback vchng, 42 | ValidatorCallback validcb) : 43 | UnsignedLong(initVal, vchng, validcb) { 44 | setRequestType(Type::Time); 45 | } 46 | 47 | uint32_t Time::toValue(const Time::TimeElements & te) { 48 | return te.timeValue; 49 | } 50 | Time::TimeElements Time::asTimeValue(uint32_t t) { 51 | return TimeElements(t); 52 | 53 | } 54 | 55 | Time::TimeElements Time::timeValue() { 56 | return asTimeValue(currentValue()); 57 | } 58 | 59 | 60 | } /* namespace Request */ 61 | } /* namespace Item */ 62 | } /* namespace Menu */ 63 | } /* namespace SerialUI */ 64 | -------------------------------------------------------------------------------- /src/AuthStoragePython.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * AuthStoragePython.cpp 3 | * 4 | * Created on: Jun 7, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | #include "includes/auth/AuthStoragePython.h" 14 | 15 | #if defined(SERIALUI_AUTHENTICATOR_ENABLE) and defined(SERIALUI_PYTHONMODULES_SUPPORT_ENABLE) 16 | #include "includes/SUIGlobals.h" 17 | 18 | #define SUIHAVE_EXTERNAL_STORAGE_AVAILABLE() \ 19 | (Globals::pythonModule() && Globals::pythonModule()->authStorage()) 20 | 21 | namespace SerialUI { 22 | namespace Auth { 23 | 24 | StoragePython::StoragePython() : Storage() { 25 | } 26 | 27 | bool StoragePython::configured(Level::Value forLevel) { 28 | if (! SUIHAVE_EXTERNAL_STORAGE_AVAILABLE()) { 29 | return false; 30 | } 31 | return Globals::pythonModule()->authStorage()->configured(forLevel); 32 | 33 | } 34 | 35 | Passphrase StoragePython::passphrase(Level::Value forLevel) { 36 | if (! SUIHAVE_EXTERNAL_STORAGE_AVAILABLE()) { 37 | return NULL; 38 | } 39 | return Globals::pythonModule()->authStorage()->passphrase(forLevel); 40 | 41 | } 42 | 43 | bool StoragePython::setPassphrase(Passphrase pass, Level::Value forLevel) { 44 | if (! SUIHAVE_EXTERNAL_STORAGE_AVAILABLE()) { 45 | return false; 46 | } 47 | return Globals::pythonModule()->authStorage()->setPassphrase(pass, forLevel); 48 | 49 | } 50 | 51 | } /* namespace Auth */ 52 | } /* namespace SerialUI */ 53 | 54 | #endif /* SERIALUI_AUTHENTICATOR_ENABLE and SERIALUI_PYTHONMODULES_SUPPORT_ENABLE */ 55 | 56 | -------------------------------------------------------------------------------- /src/SUILinuxSupport.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SUILinuxSupport.cpp 3 | * 4 | * Created on: Apr 27, 2019 5 | * Author: Pat Deegan 6 | * 7 | * SUILinuxSupport is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #include "includes/SerialUIPlatform.h" 12 | 13 | #ifdef SERIALUI_PLATFORM_LINUX 14 | 15 | #include // timeval/gettimeofday 16 | #include 17 | 18 | // #include 19 | // #include 20 | // #include 21 | // 22 | #include 23 | 24 | 25 | 26 | unsigned long int millis(void) { 27 | return micros()/1000; 28 | } 29 | unsigned long int micros(void) { 30 | static struct timeval startTime; 31 | static bool initDone = false; 32 | 33 | struct timeval nowTime; 34 | 35 | if (! initDone) 36 | { 37 | initDone = true; 38 | gettimeofday(&startTime, NULL); 39 | 40 | } 41 | gettimeofday(&nowTime, NULL); 42 | 43 | 44 | return (nowTime.tv_sec * 1000000 + (nowTime.tv_usec)) - 45 | (startTime.tv_sec * 1000000 + (startTime.tv_usec)); 46 | 47 | } 48 | void delay(unsigned long int d) { 49 | for (int i=0; i<50; i++) { 50 | delayMicroseconds(d*20); 51 | } 52 | } 53 | void delayMicroseconds(unsigned long int us) { 54 | usleep(us); 55 | } 56 | 57 | 58 | 59 | unsigned long random(unsigned long minOrMax, unsigned long max) 60 | { 61 | unsigned long diff; 62 | if (max && minOrMax) 63 | { 64 | diff = max - minOrMax; 65 | 66 | return ((random() % diff) + minOrMax); 67 | } 68 | if (minOrMax) 69 | return random() % minOrMax; 70 | 71 | return random(); 72 | } 73 | 74 | 75 | #endif /* SERIALUI_PLATFORM_LINUX */ 76 | 77 | 78 | -------------------------------------------------------------------------------- /src/ItemReqBoolean.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ItemReqBoolean.cpp 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * ItemReqBoolean is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #include "includes/menuitem/requests/ItemReqBoolean.h" 12 | #include "includes/SUIGlobals.h" 13 | namespace SerialUI { 14 | namespace Menu { 15 | namespace Item { 16 | namespace Request { 17 | 18 | 19 | Boolean::Boolean(bool initVal, ValueChangedCallback vchng, ValidatorCallback validcb) : 20 | BooleanBase(initVal, vchng, validcb) 21 | { 22 | 23 | } 24 | Boolean::Boolean(bool val, StaticString key, 25 | StaticString help, ValueChangedCallback vchng, ValidatorCallback validcb) : 26 | BooleanBase(val, key, help, vchng, validcb) 27 | { 28 | 29 | } 30 | 31 | bool Boolean::getValue(Menu * callingMenu, bool * v) { 32 | return Globals::commSource()->getBoolFor(id(), v); 33 | } 34 | 35 | 36 | ITEMPYTHONOVERRIDE_VALIDATION(BooleanBase, Boolean, bool); 37 | 38 | 39 | Toggle::Toggle(bool initVal, ValueChangedCallback vchng, ValidatorCallback validcb) : 40 | ToggleBase(initVal, vchng, validcb) 41 | { 42 | 43 | } 44 | Toggle::Toggle(bool val, StaticString key, 45 | StaticString help, ValueChangedCallback vchng, ValidatorCallback validcb) : 46 | ToggleBase(val, key, help, vchng, validcb) 47 | { 48 | 49 | } 50 | 51 | bool Toggle::getValue(Menu * callingMenu, bool * v) { 52 | return Globals::commSource()->getBoolFor(id(), v); 53 | } 54 | 55 | 56 | ITEMPYTHONOVERRIDE_VALIDATION(ToggleBase, Toggle, bool); 57 | 58 | 59 | } /* namespace Request */ 60 | } /* namespace Item */ 61 | } /* namespace Menu */ 62 | } /* namespace SerialUI */ 63 | -------------------------------------------------------------------------------- /src/includes/menuitem/requests/ItemReqColor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ItemReqColor.h 3 | * 4 | * Created on: May 13, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | #ifndef SERIALUI_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQCOLOR_H_ 14 | #define SERIALUI_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQCOLOR_H_ 15 | 16 | #include "ItemReqUnsignedLong.h" 17 | 18 | namespace SerialUI { 19 | namespace Menu { 20 | namespace Item { 21 | namespace Request { 22 | 23 | 24 | class Color : public UnsignedLong { 25 | public: 26 | Color(unsigned long int initVal=0, ValueChangedCallback vchng=NULL, 27 | ValidatorCallback validcb=NULL) : UnsignedLong(initVal, vchng, validcb) { 28 | this->setRequestType(Type::Color); 29 | } 30 | 31 | Color(unsigned long int initVal, StaticString key, 32 | StaticString help, ValueChangedCallback vchng=NULL, 33 | ValidatorCallback validcb=NULL) : UnsignedLong(initVal, key, help, vchng, validcb) { 34 | this->setRequestType(Type::Color); 35 | } 36 | 37 | uint8_t red() { 38 | return (((this->currentValue() & 0xff0000) >> 16) & 0xff); 39 | } 40 | uint8_t green() { 41 | return (((this->currentValue() & 0xff00) >> 8) & 0xff); 42 | } 43 | uint8_t blue() { 44 | return (this->currentValue() & 0xff); 45 | } 46 | 47 | 48 | }; 49 | 50 | typedef Color Colour; // 'cause we ain't all united statesians... 51 | 52 | } /* namespace Request */ 53 | } /* namespace Item */ 54 | } /* namespace Menu */ 55 | } /* namespace SerialUI */ 56 | 57 | 58 | 59 | #endif /* SERIALUI_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQCOLOR_H_ */ 60 | -------------------------------------------------------------------------------- /src/includes/menuitem/requests/ItemReqBoolean.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ItemReqBoolean.h 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * ItemReqBoolean is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUIV3_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQBOOLEAN_H_ 12 | #define SERIALUIV3_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQBOOLEAN_H_ 13 | #include "../ItemRequest.h" 14 | 15 | namespace SerialUI { 16 | namespace Menu { 17 | namespace Item { 18 | namespace Request { 19 | typedef TypedRequest BooleanBase; 20 | class Boolean : public BooleanBase { 21 | public: 22 | 23 | Boolean(bool initVal=false, ValueChangedCallback vchng=NULL, ValidatorCallback validcb=NULL); 24 | Boolean(bool initVal, StaticString key, 25 | StaticString help, ValueChangedCallback vchng=NULL, ValidatorCallback validcb=NULL); 26 | 27 | virtual bool getValue(Menu * callingMenu, bool * v); 28 | 29 | ITEMPYTHONOVERRIDE_VALIDATION_DECL(bool); 30 | }; 31 | 32 | // TODO:FIXME typedef Boolean Toggle; 33 | typedef TypedRequest ToggleBase; 34 | class Toggle : public ToggleBase { 35 | public: 36 | 37 | Toggle(bool initVal=false, ValueChangedCallback vchng=NULL, ValidatorCallback validcb=NULL); 38 | Toggle(bool initVal, StaticString key, 39 | StaticString help, ValueChangedCallback vchng=NULL, ValidatorCallback validcb=NULL); 40 | 41 | virtual bool getValue(Menu * callingMenu, bool * v); 42 | ITEMPYTHONOVERRIDE_VALIDATION_DECL(bool); 43 | }; 44 | 45 | } /* namespace Request */ 46 | } /* namespace Item */ 47 | } /* namespace Menu */ 48 | } /* namespace SerialUI */ 49 | 50 | #endif /* SERIALUIV3_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQBOOLEAN_H_ */ 51 | -------------------------------------------------------------------------------- /src/includes/menuitem/requests/ItemReqPassphrase.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ItemReqPassphrase.h 3 | * 4 | * Created on: May 7, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | #ifndef SERIALUI_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQPASSPHRASE_H_ 14 | #define SERIALUI_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQPASSPHRASE_H_ 15 | 16 | #include "ItemReqString.h" 17 | 18 | namespace SerialUI { 19 | namespace Menu { 20 | namespace Item { 21 | namespace Request { 22 | 23 | class Passphrase : public ::SerialUI::Menu::Item::Request::String { 24 | public: 25 | 26 | Passphrase(uint8_t maxlen, ValueChangedCallback vchng=NULL, 27 | ValidatorCallback validcb=NULL) : 28 | String(maxlen, vchng, validcb) { 29 | setRequestType(Type::Passphrase); 30 | } 31 | Passphrase( 32 | StaticString key, 33 | StaticString help, uint8_t maxlen, 34 | ValueChangedCallback vchng=NULL, 35 | ValidatorCallback validcb=NULL) : 36 | String(key, help, maxlen, vchng, validcb) { 37 | 38 | setRequestType(Type::Passphrase); 39 | } 40 | Passphrase(TopLevelString initVal, 41 | StaticString key, 42 | StaticString help, uint8_t maxlen, 43 | ValueChangedCallback vchng=NULL, 44 | ValidatorCallback validcb=NULL) : 45 | String(initVal, key, help, maxlen, vchng, validcb) 46 | { 47 | 48 | setRequestType(Type::Passphrase); 49 | } 50 | 51 | }; 52 | 53 | } /* namespace Request */ 54 | } /* namespace Item */ 55 | } /* namespace Menu */ 56 | } /* namespace SerialUI */ 57 | 58 | 59 | 60 | 61 | #endif /* SERIALUI_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQPASSPHRASE_H_ */ 62 | -------------------------------------------------------------------------------- /src/ItemRequest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ItemRequest.cpp 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * ItemRequest is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #include "includes/menuitem/ItemRequest.h" 12 | #include "includes/SUIGlobals.h" 13 | #include "includes/SerialUIPlatform.h" 14 | 15 | 16 | namespace SerialUI { 17 | namespace Menu { 18 | namespace Item { 19 | namespace Request { 20 | 21 | 22 | Request::Request(Type::Value rType, ValueChangedCallback vc): 23 | Item(SerialUI::Menu::Item::Type::Input), _reqType(rType), _valChangedCb(vc) { 24 | 25 | } 26 | Request::Request(Type::Value rType, StaticString key, StaticString help, ValueChangedCallback vc) : 27 | Item(SerialUI::Menu::Item::Type::Input, key, help), _reqType(rType), _valChangedCb(vc) 28 | { 29 | } 30 | 31 | 32 | Request::Request(ID id, Type::Value rType, StaticString key, StaticString help, ValueChangedCallback vc) : 33 | Item(id, SerialUI::Menu::Item::Type::Input, key, help), _reqType(rType), _valChangedCb(vc) 34 | { 35 | } 36 | 37 | 38 | 39 | void Request::valueWasModified() { 40 | 41 | if (_valChangedCb) { 42 | _valChangedCb(); 43 | } 44 | 45 | 46 | #ifdef SERIALUI_PYTHONMODULES_SUPPORT_ENABLE 47 | Python::ExternalModule * pymod = Globals::pythonModule(); 48 | if (pymod) { 49 | pymod->trigger(this); 50 | } 51 | #endif /* SERIALUI_PYTHONMODULES_SUPPORT_ENABLE */ 52 | 53 | 54 | 55 | 56 | } 57 | 58 | 59 | void Request::callBegins() { 60 | 61 | Globals::state()->gettingInput(this); 62 | 63 | } 64 | void Request::callEnds(bool successful) { 65 | Globals::state()->setIdle(); 66 | 67 | } 68 | 69 | 70 | } /* namespace Request */ 71 | } /* namespace Item */ 72 | } /* namespace Menu */ 73 | } /* namespace SerialUI */ 74 | -------------------------------------------------------------------------------- /src/AuthValidatorEquality.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * AuthValidatorEquality.cpp 3 | * 4 | * Created on: Jun 6, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | #include "includes/auth/AuthValidatorEquality.h" 14 | 15 | #ifdef SERIALUI_AUTHENTICATOR_ENABLE 16 | namespace SerialUI { 17 | namespace Auth { 18 | 19 | ValidatorEquality::ValidatorEquality(Storage * storage) : Validator(storage) { 20 | 21 | } 22 | 23 | 24 | Level::Value ValidatorEquality::grantAccess(ChallengeResponse resp) { 25 | Level::Value testLevels[] = { 26 | Level::Guest, 27 | Level::User, 28 | Level::Admin, 29 | Level::NoAccess 30 | }; 31 | SERIALUI_DEBUG_OUT(SUI_STR("ValidatorEQ ")); 32 | if (! (resp && strlen(resp))) { 33 | SERIALUI_DEBUG_OUTLN(SUI_STR("nothing2chk")); 34 | return Level::NoAccess; 35 | } 36 | 37 | if (!storage()->configured()) { 38 | SERIALUI_DEBUG_OUTLN(SUI_STR("unconfig")); 39 | return Level::NoAccess; 40 | } 41 | uint8_t idx = 0; 42 | while (testLevels[idx] != Level::NoAccess) { 43 | Passphrase pass = storage()->passphrase(testLevels[idx]); 44 | 45 | if (pass) { 46 | SERIALUI_DEBUG_OUT(SUI_STR("comparing '")); 47 | SERIALUI_DEBUG_OUT(resp); 48 | SERIALUI_DEBUG_OUT(SUI_STR("' to ")); 49 | SERIALUI_DEBUG_OUTLN(pass); 50 | int cmpval = strcmp(pass, resp) ; 51 | if (cmpval == 0) { 52 | SERIALUI_DEBUG_OUTLN(SUI_STR("HUZZAH")); 53 | return testLevels[idx]; 54 | } else { 55 | SERIALUI_DEBUG_OUTLN(cmpval); 56 | } 57 | } 58 | idx++; 59 | } 60 | return Level::NoAccess; 61 | 62 | } 63 | 64 | } /* namespace Auth */ 65 | } /* namespace SerialUI */ 66 | 67 | 68 | #endif /* SERIALUI_AUTHENTICATOR_ENABLE */ 69 | -------------------------------------------------------------------------------- /src/AuthValidatorPython.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * AuthValidatorPython.cpp 3 | * 4 | * Created on: Jun 7, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | #include "includes/auth/AuthValidatorPython.h" 14 | 15 | #if defined(SERIALUI_AUTHENTICATOR_ENABLE) and defined(SERIALUI_PYTHONMODULES_SUPPORT_ENABLE) 16 | #include "includes/SUIGlobals.h" 17 | 18 | #define SUIHAVE_EXTERNAL_VALIDATOR_AVAILABLE() \ 19 | (Globals::pythonModule() && Globals::pythonModule()->authValidator()) 20 | 21 | namespace SerialUI { 22 | namespace Auth { 23 | 24 | ValidatorPython::ValidatorPython(Storage * storage) : Validator(storage) { 25 | 26 | 27 | } 28 | 29 | Challenge ValidatorPython::challenge(Level::Value forLevel) { 30 | if (! SUIHAVE_EXTERNAL_VALIDATOR_AVAILABLE()) { 31 | SERIALUI_DEBUG_OUTLN(F("No ext validator")); 32 | return NULL; 33 | } 34 | 35 | return Globals::pythonModule()->authValidator()->challenge(forLevel); 36 | 37 | } 38 | 39 | Level::Value ValidatorPython::grantAccess(ChallengeResponse resp) { 40 | if (! SUIHAVE_EXTERNAL_VALIDATOR_AVAILABLE()) { 41 | SERIALUI_DEBUG_OUTLN(F("No ext validator")); 42 | return Level::NoAccess; 43 | } 44 | 45 | return Globals::pythonModule()->authValidator()->grantAccess(resp); 46 | 47 | } 48 | 49 | Transmission::Type::Value ValidatorPython::communicationType() { 50 | if (! SUIHAVE_EXTERNAL_VALIDATOR_AVAILABLE()) { 51 | SERIALUI_DEBUG_OUTLN(F("No ext validator")); 52 | return Transmission::Type::Custom; 53 | } 54 | 55 | return Globals::pythonModule()->authValidator()->communicationType(); 56 | 57 | } 58 | 59 | } /* namespace Auth */ 60 | } /* namespace SerialUI */ 61 | 62 | #endif /* SERIALUI_AUTHENTICATOR_ENABLE and SERIALUI_PYTHONMODULES_SUPPORT_ENABLE */ 63 | 64 | 65 | -------------------------------------------------------------------------------- /src/includes/comm/CommRequest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * CommRequest.h 3 | * 4 | * Created on: May 28, 2018 5 | * Author: Pat Deegan 6 | * 7 | * CommRequest is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUI_SRC_INCLUDES_COMM_COMMREQUEST_H_ 12 | #define SERIALUI_SRC_INCLUDES_COMM_COMMREQUEST_H_ 13 | 14 | #include "../SerialUITypes.h" 15 | #include "../menuitem/MenuItem.h" 16 | namespace SerialUI { 17 | namespace Comm { 18 | 19 | typedef struct RequestStruct { 20 | public: 21 | uint8_t requestId; 22 | SerialUI::Request::Type::Value requestType; 23 | union { 24 | Menu::Item::Item * menuItem; 25 | SerialUI::Request::BuiltIn::Selection builtIn; 26 | }; 27 | RequestStruct() : requestId(0), requestType(SerialUI::Request::Type::INVALID), menuItem(NULL) {} 28 | RequestStruct(SerialUI::Request::BuiltIn::Selection selectedAction) : 29 | requestId(0), 30 | requestType(SerialUI::Request::Type::BuiltIn), builtIn(selectedAction) {} 31 | RequestStruct(Menu::Item::Item * selectedItem) : requestId(0), 32 | requestType(SerialUI::Request::Type::MenuItem), menuItem(selectedItem) {} 33 | 34 | 35 | void setMenuItem(Menu::Item::Item * selectedItem); 36 | void setBuiltIn(SerialUI::Request::BuiltIn::Selection); 37 | 38 | void clear() { 39 | requestType = SerialUI::Request::Type::INVALID; 40 | menuItem = NULL; 41 | requestId = 0; 42 | } 43 | 44 | bool isValid() const { 45 | return requestType != SerialUI::Request::Type::INVALID; 46 | } 47 | 48 | bool isForMenuItem() const { 49 | return requestType == SerialUI::Request::Type::MenuItem; 50 | } 51 | 52 | bool isForBuiltIn() const { 53 | return requestType == SerialUI::Request::Type::BuiltIn; 54 | } 55 | 56 | bool trigger(Menu::Menu * fromMenu); 57 | 58 | 59 | } Request; 60 | 61 | } /* namespace Comm */ 62 | } /* namespace SerialUI */ 63 | 64 | #endif /* SERIALUI_SRC_INCLUDES_COMM_COMMREQUEST_H_ */ 65 | -------------------------------------------------------------------------------- /src/includes/menuitem/ItemTrackedView.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ItemTrackedView.h 3 | * 4 | * Created on: Sep 27, 2018 5 | * Author: Pat Deegan 6 | * 7 | * ItemTrackedView is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUI_SRC_INCLUDES_MENUITEM_ITEMTRACKEDVIEW_H_ 12 | #define SERIALUI_SRC_INCLUDES_MENUITEM_ITEMTRACKEDVIEW_H_ 13 | 14 | 15 | #include "MenuItem.h" 16 | #include "../Menu.h" 17 | #include "../tracked/TrackedVariable.h" 18 | 19 | #ifndef SERIALUI_TRACKEDVIEW_MAXNUM_STATES 20 | #define SERIALUI_TRACKEDVIEW_MAXNUM_STATES SERIALUI_TRACKEDVIEW_MAXNUM_STATES_DEFAULT 21 | #endif 22 | 23 | namespace SerialUI { 24 | namespace Menu { 25 | namespace Item { 26 | 27 | class TrackedView : public Item { 28 | public: 29 | 30 | TrackedView(Tracked::View::Type vType, StaticString key, StaticString help); 31 | TrackedView(ID id, Tracked::View::Type vType, StaticString key, StaticString help); 32 | 33 | virtual void call(Menu * callingMenu) {} 34 | 35 | inline Tracked::View::Type viewType() { return _viewType;} 36 | inline uint8_t numAssociated() { return _num;} 37 | inline Tracked::State* associatedByIdx(uint8_t i) { return trackedVars[i];} 38 | bool associate(Tracked::State & st); 39 | 40 | private: 41 | Tracked::View::Type _viewType; 42 | uint8_t _num; 43 | Tracked::State * trackedVars[SERIALUI_TRACKEDVIEW_MAXNUM_STATES]; 44 | }; 45 | 46 | template 47 | class TrackedViewImpl : public TrackedView { 48 | public: 49 | TrackedViewImpl(StaticString key, StaticString help) : 50 | TrackedView(SUBTYPE, key, help) {} 51 | 52 | TrackedViewImpl(ID id, StaticString key, StaticString help): 53 | TrackedView(id, SUBTYPE, key, help) {} 54 | 55 | 56 | }; 57 | 58 | 59 | } /* namespace Item */ 60 | } /* namespace Menu */ 61 | } /* namespace SerialUI */ 62 | 63 | 64 | 65 | #endif /* SERIALUI_SRC_INCLUDES_MENUITEM_ITEMTRACKEDVIEW_H_ */ 66 | -------------------------------------------------------------------------------- /src/AuthStorageStatic.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * AuthStorageStatic.cpp 3 | * 4 | * Created on: Jun 6, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | #include "includes/auth/AuthStorageStatic.h" 14 | 15 | #ifdef SERIALUI_AUTHENTICATOR_ENABLE 16 | namespace SerialUI { 17 | namespace Auth { 18 | 19 | StorageStatic::StorageStatic(Passphrase adminPass, 20 | Passphrase userPass, 21 | Passphrase guestPass) : Storage() 22 | { 23 | stored_pass[(uint8_t)Level::NoAccess] = NULL; 24 | stored_pass[(uint8_t)Level::Guest] = guestPass; 25 | stored_pass[(uint8_t)Level::User] = userPass; 26 | stored_pass[(uint8_t)Level::Admin] = adminPass; 27 | for (uint8_t i=0; i<4; i++) { 28 | uconfiged_pass[i] = NULL; 29 | } 30 | 31 | } 32 | 33 | bool StorageStatic::setPassphrase(Passphrase pass, Level::Value forLevel) { 34 | uint8_t levIdx = (uint8_t)forLevel; 35 | if (uconfiged_pass[levIdx]) { 36 | delete[] uconfiged_pass[levIdx]; 37 | } 38 | if (! pass) { 39 | uconfiged_pass[levIdx] = NULL; 40 | stored_pass[levIdx] = NULL; 41 | return true; 42 | } 43 | uint8_t passLen = strlen(pass); 44 | 45 | uconfiged_pass[levIdx] = new char[passLen + 1]; 46 | if (! uconfiged_pass[levIdx]) { 47 | return false; 48 | } 49 | uconfiged_pass[levIdx][passLen] = 0; 50 | strcpy(uconfiged_pass[levIdx], pass); 51 | stored_pass[levIdx] = uconfiged_pass[levIdx]; 52 | return true; 53 | } 54 | bool StorageStatic::configured(Level::Value forLevel) { 55 | if (! stored_pass[(uint8_t)forLevel]) { 56 | return false; 57 | } 58 | return true; 59 | } 60 | 61 | Passphrase StorageStatic::passphrase(Level::Value forLevel) { 62 | return stored_pass[(uint8_t)forLevel]; 63 | } 64 | 65 | } /* namespace Auth */ 66 | } /* namespace SerialUI */ 67 | 68 | 69 | #endif /* SERIALUI_AUTHENTICATOR_ENABLE */ 70 | -------------------------------------------------------------------------------- /src/includes/platform/SUIPlatLinux.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SUIPlatLinux.h 3 | * 4 | * Created on: Apr 27, 2019 5 | * Author: Pat Deegan 6 | * 7 | * SUIPlatArduino is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUI_SRC_INCLUDES_PLATFORM_SUIPLATLINUX_H_ 12 | #define SERIALUI_SRC_INCLUDES_PLATFORM_SUIPLATLINUX_H_ 13 | 14 | #include 15 | 16 | 17 | #include "linux/SUILinuxSupport.h" 18 | #include "linux/LinuxBLESerial.h" 19 | 20 | #define SERIALUI_CHANNELS_USE_STANDARDSTREAMS 21 | 22 | #define SERIALUI_SERIALIZER_JSON_ENABLE 23 | #define SERIALUI_PYTHONMODULES_SUPPORT_ENABLE 24 | 25 | #define SERIALUI_MENUSTRUCTURE_NUMITEMS_ATSTARTUP 50 26 | #define SERIALUI_MENUSTRUCTURE_NUMITEMS_GROWLIST 25 27 | 28 | #define SERIALUI_TRACKEDVIEW_MAXNUM_STATES 10 29 | #define SERIALUI_TRACKING_NUMITEMS_ATSTARTUP 10 30 | 31 | 32 | #define SERIALUI_AUTHENTICATOR_ENABLE 33 | 34 | 35 | #define SUI_PLATFORM_SOURCE_DEFAULT _linBLESerial 36 | 37 | #define SUI_STR(...) (__VA_ARGS__) 38 | 39 | #define SUI_PLATFORM_TIMENOW_MS() millis() 40 | #define SUI_PLATFORM_DELAY_MS(d) delay(d) 41 | #ifndef F 42 | #define F(...) (__VA_ARGS__) 43 | #endif 44 | 45 | namespace SerialUI { 46 | 47 | #define SUI_FLASHSTRING const char * 48 | typedef const char * StaticString; 49 | typedef const char * DynamicString; 50 | 51 | // define SUI_STATICSTRING_IS_DISTINCT_TYPE 52 | #define SUI_PLATFORM_STATICSTRING_LENGTH(s) strlen(reinterpret_cast(s)) 53 | 54 | 55 | 56 | 57 | 58 | 59 | namespace Comm { 60 | 61 | typedef Stream SourceBase; 62 | typedef Print SinkBase; 63 | typedef LinuxBLESerial SourceType; 64 | 65 | 66 | } 67 | 68 | } 69 | 70 | #ifdef SERIALUI_ENABLE_DEBUG_OUTPUT 71 | #define SERIALUI_DEBUG_OUT(...) std::cerr << __VA_ARGS__ 72 | #define SERIALUI_DEBUG_OUTLN(...) std::cerr << __VA_ARGS__ << std::endl 73 | #endif 74 | 75 | #endif /* SERIALUI_SRC_INCLUDES_PLATFORM_SUIPLATLINUX_H_ */ 76 | -------------------------------------------------------------------------------- /src/includes/platform/SUIPlatNRF52Arduino.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SUIPlatnRF52Arduino.h 3 | * 4 | * Created on: Oct 13, 2018 5 | * Author: Pat Deegan 6 | * 7 | * SUIPlatnRF52Arduino is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUI_SRC_INCLUDES_PLATFORM_SUIPLATNRF52ARDUINO_H_ 12 | #define SERIALUI_SRC_INCLUDES_PLATFORM_SUIPLATNRF52ARDUINO_H_ 13 | 14 | #include 15 | 16 | 17 | #define SERIALUI_AUTHENTICATOR_ENABLE 18 | 19 | 20 | 21 | #define SERIALUI_MENUSTRUCTURE_NUMITEMS_ATSTARTUP 20 22 | #define SERIALUI_MENUSTRUCTURE_NUMITEMS_GROWLIST 10 23 | 24 | #define SERIALUI_TRACKEDVIEW_MAXNUM_STATES 8 25 | #define SERIALUI_TRACKING_NUMITEMS_ATSTARTUP 10 26 | 27 | #define SERIALUI_CHANNELS_USE_STANDARDSTREAMS 28 | #define SUI_PLATFORM_SOURCE_DEFAULT SUIBLESerialDev 29 | 30 | #define SUI_STR(...) F(__VA_ARGS__) 31 | 32 | #define SUI_PLATFORM_TIMENOW_MS() millis() 33 | #define SUI_PLATFORM_DELAY_MS(d) delay(d) 34 | 35 | #include "nrf52/NRF52BLESerial.h" 36 | 37 | namespace SerialUI { 38 | 39 | #define SUI_FLASHSTRING const __FlashStringHelper* 40 | typedef const __FlashStringHelper* StaticString; 41 | typedef const char * DynamicString; 42 | 43 | #define SUI_STATICSTRING_IS_DISTINCT_TYPE 44 | #define SUI_PLATFORM_STATICSTRING_LENGTH(s) strlen(reinterpret_cast(s)) 45 | 46 | 47 | namespace Comm { 48 | 49 | typedef Stream SourceBase; 50 | typedef Print SinkBase; 51 | #ifdef DESKTOP_COMPILE 52 | typedef GlobalSerialWrapper SourceType; 53 | #else 54 | typedef NRF52BLESerial SourceType; 55 | #endif 56 | 57 | } 58 | 59 | } 60 | 61 | 62 | #ifdef SERIALUI_ENABLE_DEBUG_OUTPUT 63 | #define SERIALUI_BEGIN_DEBUGOUTCHANNEL(...) Serial.begin(57600) 64 | #define SERIALUI_DEBUG_OUT(...) Serial.print( __VA_ARGS__ ) 65 | #define SERIALUI_DEBUG_OUTLN(...) Serial.println( __VA_ARGS__ ) 66 | #endif 67 | 68 | 69 | 70 | 71 | 72 | #endif /* SERIALUI_SRC_INCLUDES_PLATFORM_SUIPLATNRF52ARDUINO_H_ */ 73 | -------------------------------------------------------------------------------- /src/includes/SerialUIPlatform.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SerialUIPlatform.h 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * SerialUIPlatform is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUIV3_SRC_INCLUDES_SERIALUIPLATFORM_H_ 12 | #define SERIALUIV3_SRC_INCLUDES_SERIALUIPLATFORM_H_ 13 | 14 | #include "SerialUIConfig.h" 15 | 16 | #include "platform/detect/SUIPlatDetect.h" 17 | 18 | #ifdef SERIALUI_PLATFORM_ARDUINOSTANDARD 19 | #ifdef SERIALUI_WARN_PLATFORM_DETECTION_DEBUG 20 | #warning "PLATFORM: Arduino standard" 21 | #endif /* SERIALUI_WARN_PLATFORM_DETECTION_DEBUG */ 22 | #include "platform/SUIPlatArduino.h" 23 | #define SUI_PLATDETECT_SUCCESS 24 | #endif 25 | 26 | 27 | #ifdef SERIALUI_PLATFORM_NRF52 28 | #ifdef SERIALUI_WARN_PLATFORM_DETECTION_DEBUG 29 | #warning "PLATFORM: NRF52" 30 | #endif /* SERIALUI_WARN_PLATFORM_DETECTION_DEBUG */ 31 | #include "platform/SUIPlatNRF52Arduino.h" 32 | #define SUI_PLATDETECT_SUCCESS 33 | #endif 34 | 35 | 36 | #ifdef SERIALUI_PLATFORM_LINUX 37 | #ifdef SERIALUI_WARN_PLATFORM_DETECTION_DEBUG 38 | #warning "PLATFORM: Linux" 39 | #endif /* SERIALUI_WARN_PLATFORM_DETECTION_DEBUG */ 40 | #include "platform/SUIPlatLinux.h" 41 | #define SUI_PLATDETECT_SUCCESS 42 | #endif 43 | 44 | #ifndef SUI_PLATDETECT_SUCCESS 45 | #warning "SERIALUI FAIL: Could not detect platform?" 46 | #endif 47 | 48 | 49 | namespace SerialUI { 50 | 51 | 52 | size_t staticStringLength(StaticString aKey); 53 | 54 | bool staticStringMatch(StaticString aKey, 55 | DynamicString theTest, 56 | bool allowPartials=true); 57 | } 58 | 59 | #ifndef SERIALUI_DEBUG_OUT 60 | #define SERIALUI_DEBUG_OUT(...) 61 | #endif 62 | 63 | #ifndef SERIALUI_DEBUG_OUTLN 64 | #define SERIALUI_DEBUG_OUTLN(...) 65 | #endif 66 | 67 | #ifndef SERIALUI_BEGIN_DEBUGOUTCHANNEL 68 | #define SERIALUI_BEGIN_DEBUGOUTCHANNEL(...) 69 | #endif 70 | 71 | #ifndef F 72 | #define F(...) __VA_ARGS__ 73 | #endif 74 | 75 | #endif /* SERIALUIV3_SRC_INCLUDES_SERIALUIPLATFORM_H_ */ 76 | -------------------------------------------------------------------------------- /src/includes/menuitem/requests/ItemReqBoundedLong.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ItemReqBoundedLong.h 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * ItemReqBoundedLong is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUIV3_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQBOUNDEDLONG_H_ 12 | #define SERIALUIV3_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQBOUNDEDLONG_H_ 13 | 14 | #include "../ItemRequest.h" 15 | 16 | namespace SerialUI { 17 | namespace Menu { 18 | namespace Item { 19 | namespace Request { 20 | 21 | class BoundedLong: public COUNTABLEREQCLASS_PARENT(Type::BoundedLongInt, long int, BoundedLong) { 22 | public: 23 | BoundedLong(long int initVal, 24 | StaticString key, 25 | StaticString help, 26 | long int min, long int max, 27 | ValueChangedCallback vchng=NULL, 28 | ValidatorCallback validcb=NULL); 29 | 30 | BoundedLong( 31 | long int initVal=0, 32 | long int min=0, long int max=1, 33 | ValueChangedCallback vchng=NULL, 34 | ValidatorCallback validcb=NULL); 35 | 36 | 37 | virtual bool getValue(Menu * callingMenu, long int * v); 38 | virtual bool valueIsValid(long int & val) ; 39 | 40 | inline void setStep(uint8_t val) { if (val) { _stepVal = val;}} 41 | inline long int minimum() { return _minAllowed;} 42 | inline long int maximum() { return _maxAllowed;} 43 | inline uint8_t step() { return _stepVal;} 44 | 45 | COUTABLEREQCLASS_USINGALLOPS(Type::BoundedLongInt, long int, BoundedLong); 46 | 47 | ITEMPYTHONOVERRIDE_VALIDATION_DECL(long int); 48 | 49 | protected: 50 | inline void setMinimum(long int i) { _minAllowed = i;} 51 | inline void setMaximum(long int i) { _maxAllowed = i;} 52 | void ensureSaneBounds(); 53 | 54 | private: 55 | 56 | long int _minAllowed; 57 | long int _maxAllowed; 58 | uint8_t _stepVal; 59 | }; 60 | 61 | } /* namespace Request */ 62 | } /* namespace Item */ 63 | } /* namespace Menu */ 64 | } /* namespace SerialUI */ 65 | 66 | #endif /* SERIALUIV3_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQBOUNDEDLONG_H_ */ 67 | -------------------------------------------------------------------------------- /src/SerialUI.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SerialUI.h 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2014-2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | * 12 | * SerialUI provides an embedded/host-side user interface, comprised of menus 13 | * consisting of 14 | * - commands (orders to take action); 15 | * - inputs (user-supplied data, as text or numeric values); 16 | * - data views (various views of evolving state); and 17 | * - sub-menus containing more of the above; 18 | * 19 | * What the host does with the data, or when commands are received 20 | * from the user, is up to the programmer implementing the body of the 21 | * various callbacks that are triggered in response. 22 | * 23 | * SerialUI is designed to provide both "raw" (low-level) access to the 24 | * functionality, through e.g. a USB serial connection, and to allow for 25 | * programatic access through the device druid client application. 26 | * 27 | * See https://devicedruid.com/ for more info. 28 | * 29 | */ 30 | 31 | #ifndef SERIALUIV3_SRC_SERIALUI_H_ 32 | #define SERIALUIV3_SRC_SERIALUI_H_ 33 | 34 | #include "includes/menuitem/items.h" 35 | #include "includes/tracked/tracked.h" 36 | #include "includes/SerialUI.h" 37 | #include "includes/SUIGlobals.h" 38 | 39 | #include "includes/SerialUIPlatform.h" 40 | 41 | #ifdef SERIALUI_BUILD_TESTS 42 | #include "includes/test/tests.h" 43 | #endif 44 | 45 | #ifdef SERIALUI_SERIALIZER_JSON_ENABLE 46 | #include "includes/settings/SerializerJson.h" 47 | #include "includes/settings/DeSerializerJson.h" 48 | #endif 49 | 50 | #ifdef SERIALUI_PLATFORM_LINUX 51 | #include "includes/platform/linux/LinuxStorageFilesystem.h" 52 | #include "includes/python/ExternalModule.h" 53 | #endif 54 | 55 | #ifdef SERIALUI_AUTHENTICATOR_ENABLE 56 | #include "includes/auth/Authenticator.h" 57 | #include "includes/auth/AuthSimple.h" 58 | #endif 59 | 60 | #endif /* SERIALUIV3_SRC_SERIALUI_H_ */ 61 | -------------------------------------------------------------------------------- /src/includes/menuitem/requests/ItemReqOptions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ItemReqOptions.h 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * ItemReqOptions is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUIV3_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQOPTIONS_H_ 12 | #define SERIALUIV3_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQOPTIONS_H_ 13 | 14 | #include "ItemReqBoundedLong.h" 15 | 16 | #define SERIALUI_MENUITEM_OPTLIST_MAXOPTIONS 6 17 | 18 | namespace SerialUI { 19 | namespace Menu { 20 | namespace Item { 21 | namespace Request { 22 | 23 | class OptionsList : public BoundedLong { 24 | public: 25 | OptionsList(long int initVal=0, ValueChangedCallback vchng=NULL, 26 | ValidatorCallback validcb=NULL); 27 | OptionsList(long int initVal, StaticString key, 28 | StaticString help, 29 | StaticString opt1, 30 | StaticString opt2, 31 | StaticString opt3 = NULL, 32 | StaticString opt4 = NULL, 33 | StaticString opt5 = NULL, 34 | StaticString opt6 = NULL, 35 | ValueChangedCallback vchng=NULL, 36 | ValidatorCallback validcb=NULL); 37 | 38 | virtual void freeResources() ; 39 | 40 | void setOptions( 41 | StaticString opt1, 42 | StaticString opt2, 43 | StaticString opt3 = NULL, 44 | StaticString opt4 = NULL, 45 | StaticString opt5 = NULL, 46 | StaticString opt6 = NULL); 47 | 48 | StaticString currentSelection(); 49 | 50 | StaticString optionBySelection(uint8_t idx) ; 51 | StaticString optionByIndex(uint8_t idx); 52 | inline uint8_t numOptions() { return _numOptions;} 53 | private: 54 | void doInit( 55 | StaticString opt1, 56 | StaticString opt2, 57 | StaticString opt3 = NULL, 58 | StaticString opt4 = NULL, 59 | StaticString opt5 = NULL, 60 | StaticString opt6 = NULL); 61 | 62 | StaticString * opts; 63 | uint8_t _numOptions; 64 | 65 | 66 | }; 67 | 68 | } /* namespace Request */ 69 | } /* namespace Item */ 70 | } /* namespace Menu */ 71 | } /* namespace SerialUI */ 72 | 73 | #endif /* SERIALUIV3_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQOPTIONS_H_ */ 74 | -------------------------------------------------------------------------------- /src/SUIGlobals.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SUIGlobals.cpp 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * SUIGlobals is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #include "includes/SUIGlobals.h" 12 | #include "includes/comm/ChannelManager.h" 13 | 14 | #define SUIGLOBS_SIMPLESING(tp) \ 15 | static tp * _glob_sing = NULL; \ 16 | if (_glob_sing) { \ 17 | return _glob_sing; \ 18 | } \ 19 | _glob_sing = new tp(); \ 20 | return _glob_sing 21 | 22 | 23 | namespace SerialUI { 24 | 25 | Globals::Globals() { 26 | // TODO Auto-generated constructor stub 27 | 28 | } 29 | 30 | 31 | State * Globals::state() { 32 | SUIGLOBS_SIMPLESING(State); 33 | } 34 | 35 | Menu::Structure * Globals::menuStructure() { 36 | SUIGLOBS_SIMPLESING(Menu::Structure); 37 | } 38 | 39 | 40 | Menu::Tracking * Globals::trackedStates() { 41 | SUIGLOBS_SIMPLESING(Menu::Tracking); 42 | 43 | } 44 | 45 | Comm::Channel * Globals::commChannel() { 46 | return Comm::ChannelManager::currentChannel(); 47 | } 48 | 49 | Comm::Source * Globals::commSource() { 50 | return Comm::ChannelManager::currentChannel(); 51 | } 52 | 53 | 54 | #ifdef SERIALUI_PYTHONMODULES_SUPPORT_ENABLE 55 | static SerialUI::Python::ExternalModule * curPythonModule = NULL; 56 | 57 | Python::ExternalModule * Globals::pythonModule() { 58 | return curPythonModule; 59 | } 60 | bool Globals::setPythonModule(Python::ExternalModule * mod) { 61 | if (! mod) { 62 | curPythonModule = NULL; 63 | return true; 64 | } 65 | 66 | curPythonModule = mod; 67 | 68 | if (! mod->load()) { 69 | return false; 70 | } 71 | return true; 72 | } 73 | #endif /* SERIALUI_PYTHONMODULES_SUPPORT_ENABLE */ 74 | 75 | #ifdef SERIALUI_AUTHENTICATOR_ENABLE 76 | static Auth::Authenticator * curAuthenticatorObj = NULL; 77 | 78 | Auth::Authenticator * Globals::authenticator() { 79 | return curAuthenticatorObj; 80 | } 81 | void Globals::setAuthenticator(Auth::Authenticator* auth) { 82 | curAuthenticatorObj = auth; 83 | } 84 | #endif /* SERIALUI_AUTHENTICATOR_ENABLE */ 85 | 86 | } /* namespace SerialUI */ 87 | -------------------------------------------------------------------------------- /src/includes/Menu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Menu.h 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * Menu is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUIV3_SRC_INCLUDES_MENU_H_ 12 | #define SERIALUIV3_SRC_INCLUDES_MENU_H_ 13 | #include "SerialUITypes.h" 14 | 15 | 16 | 17 | namespace SerialUI { 18 | namespace Menu { 19 | 20 | namespace Item { 21 | class Item; // forward decl 22 | class Command; 23 | class TrackedView; 24 | namespace Request { 25 | class Request; // forward decl 26 | } 27 | } 28 | 29 | class Menu { 30 | public: 31 | Menu(); 32 | virtual ~Menu() ; 33 | virtual Item::ID id() = 0; 34 | 35 | virtual uint8_t numItems() = 0; 36 | virtual Item::Item * itemById(Item::ID itemId) = 0; 37 | virtual Item::Item * itemByIndex(uint8_t idx) = 0; 38 | virtual Item::Item * itemByKey(DynamicString keyToFind) = 0; 39 | 40 | // NOTE: -1 == NOT FOUND 41 | virtual int8_t indexForItem(Item::ID itemId) = 0; 42 | 43 | 44 | /* 45 | * 46 | UpLevel = 0x01, 47 | ModeUser = 0x02, 48 | ModeProgram = 0x03, 49 | ListMenu = 0x04, 50 | Help = 0x05, 51 | RefreshTracked = 0x06, 52 | */ 53 | 54 | virtual void upLevel() = 0; 55 | virtual void outputListing() = 0; 56 | virtual void outputHelp() = 0; 57 | virtual void switchMode(Mode::Selection switchTo) = 0; 58 | virtual uint8_t refreshTracking(bool force=false) = 0; 59 | 60 | virtual bool addView(Item::TrackedView & trackedView) = 0; 61 | 62 | virtual bool addText(StaticString title, 63 | StaticString contents=NULL) = 0; 64 | 65 | virtual bool addCommand(StaticString key_str, Item::CommandCallback callback, 66 | StaticString help_str=NULL) = 0; 67 | 68 | virtual bool addRequest(Item::Request::Request & req) = 0; 69 | 70 | 71 | virtual Menu * subMenu(StaticString key_str, StaticString help_str=NULL) = 0; 72 | virtual Menu * addGroup(StaticString key_str, StaticString help_str=NULL) = 0; 73 | virtual Menu * addList(StaticString key_str, StaticString help_str=NULL) = 0; 74 | 75 | }; 76 | 77 | } /* namespace Menu */ 78 | } /* namespace SerialUI */ 79 | 80 | #endif /* SERIALUIV3_SRC_INCLUDES_MENU_H_ */ 81 | -------------------------------------------------------------------------------- /src/ItemReqEvent.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ItemReqEvent.cpp 3 | * 4 | * Created on: Jun 2, 2018 5 | * Author: Pat Deegan 6 | * 7 | * ItemReqEvent is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #include "includes/menuitem/requests/ItemReqEvent.h" 12 | 13 | namespace SerialUI { 14 | namespace Menu { 15 | namespace Item { 16 | namespace Request { 17 | 18 | Event::TimeElements Event::asTimeValue(uint32_t t) { 19 | Event::TimeElements te(t); 20 | return te; 21 | } 22 | 23 | uint32_t Event::toValue(const TimeElements& te) { 24 | return te.timeValue; 25 | } 26 | 27 | Event::Event(uint8_t startHour, uint8_t startMinute, uint8_t startSeconds, 28 | uint16_t durationMinutes, 29 | StaticString key, 30 | StaticString help, 31 | ValueChangedCallback vchng, 32 | ValidatorCallback validcb) : 33 | UnsignedLong( 34 | TimeElements(startHour, startMinute, startSeconds, durationMinutes).timeValue, 35 | key, help, 36 | vchng, validcb){ 37 | setRequestType(Type::Event); 38 | 39 | } 40 | 41 | Event::Event(unsigned long int initVal, ValueChangedCallback vchng, 42 | ValidatorCallback validcb) : 43 | UnsignedLong(initVal, vchng, validcb){ 44 | setRequestType(Type::Event); 45 | } 46 | 47 | Event::Event(unsigned long int initVal, StaticString key, StaticString help, 48 | ValueChangedCallback vchng, ValidatorCallback validcb) : 49 | UnsignedLong(initVal, key, help, vchng, validcb) { 50 | setRequestType(Type::Event); 51 | } 52 | 53 | void Event::setAt(const TimeElements& te) { 54 | this->setValue(te.timeValue); 55 | } 56 | 57 | void Event::setDay(Weekday::day day) { 58 | Event::TimeElements te(this->timeValue()); 59 | te.day = day; 60 | setAt(te); 61 | } 62 | 63 | void Event::setStart(uint8_t hour, uint8_t minute, uint8_t seconds) { 64 | 65 | Event::TimeElements te(this->timeValue()); 66 | te.startHour = hour; 67 | te.startMinute = minute; 68 | te.startSecond = seconds; 69 | 70 | setAt(te); 71 | } 72 | 73 | Event::TimeElements Event::timeValue() { 74 | return toValue(this->currentValue()); 75 | } 76 | 77 | } /* namespace Request */ 78 | } /* namespace Item */ 79 | } /* namespace Menu */ 80 | } /* namespace SerialUI */ 81 | -------------------------------------------------------------------------------- /src/includes/tracked/TrackedString.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TrackedString.h 3 | * 4 | * Created on: May 26, 2018 5 | * Author: Pat Deegan 6 | * 7 | * TrackedString is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUI_SRC_INCLUDES_TRACKED_TRACKEDSTRING_H_ 12 | #define SERIALUI_SRC_INCLUDES_TRACKED_TRACKEDSTRING_H_ 13 | 14 | #include "TrackedVariable.h" 15 | 16 | namespace SerialUI { 17 | namespace Tracked { 18 | 19 | 20 | class String: public StateImplComparable 21 | { 22 | public: 23 | String(StaticString name) : StateImplComparable(name, "") {} 24 | String(StaticString name, TopLevelString s) : StateImplComparable(name, s) {} 25 | String(StaticString name, ID sid, TopLevelString v) : StateImplComparable(name, sid, v) {} 26 | 27 | String& operator+= (TopLevelString v); 28 | String operator+(const TopLevelString& b) const; 29 | 30 | 31 | String& operator= (const char *cstr) ; 32 | String & operator += (const char *cstr); 33 | String & operator += (char c) ; 34 | String & operator += (unsigned char num); 35 | String & operator += (int num) ; 36 | String & operator += (unsigned int num); 37 | String & operator += (long num) ; 38 | String & operator += (unsigned long num); 39 | String & operator += (float num) ; 40 | String & operator += (double num); 41 | char operator [] (unsigned int index) const ; 42 | char& operator [] (unsigned int index) ; 43 | 44 | 45 | virtual void printValueTo(Comm::Sink * toSink, bool asBinary=false) const { 46 | if (asBinary) { 47 | toSink->write(this->value.length()); 48 | } 49 | toSink->print(this->value); 50 | 51 | } 52 | 53 | #ifndef DESKTOP_COMPILE 54 | // very arduino-specific 55 | char charAt(unsigned int index) const ; 56 | void setCharAt(unsigned int index, char c) ; 57 | 58 | // parsing/conversion 59 | long toInt(void) const ; 60 | float toFloat(void) const ; 61 | double toDouble(void) const ; 62 | #endif 63 | 64 | 65 | }; 66 | 67 | 68 | } /* namespace Tracked */ 69 | } /* namespace SerialUI */ 70 | 71 | #endif /* SERIALUI_SRC_INCLUDES_TRACKED_TRACKEDSTRING_H_ */ 72 | -------------------------------------------------------------------------------- /src/includes/menuitem/MenuItem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MenuItem.h 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * MenuItem is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUIV3_SRC_INCLUDES_MENUITEM_MENUITEM_H_ 12 | #define SERIALUIV3_SRC_INCLUDES_MENUITEM_MENUITEM_H_ 13 | 14 | #include "../SerialUITypes.h" 15 | 16 | 17 | namespace SerialUI { 18 | namespace Menu { 19 | 20 | class Menu; // forward decl 21 | 22 | 23 | namespace Item { 24 | 25 | class Item { 26 | public: 27 | Item(Type::Value itemType); 28 | Item(ID id, Type::Value itemType, StaticString key, StaticString help); 29 | Item(Type::Value itemType, StaticString key, StaticString help); 30 | virtual ~Item() {} 31 | 32 | virtual void call(Menu * callingMenu) = 0; 33 | 34 | virtual ID id() { return _id;} 35 | inline void setId(ID id) { _id = id;} 36 | 37 | Item * parent(); 38 | 39 | inline ID parentId() { return _parentId;} 40 | inline void setParentId(ID pid) { _parentId = pid;} 41 | 42 | 43 | inline StaticStringLength lengthKey() { 44 | return stringLength(_key); 45 | } 46 | inline StaticStringLength lengthHelp() { 47 | return stringLength(_help); 48 | } 49 | 50 | inline void setKey(StaticString k) { _key = k;} 51 | inline void setHelp(StaticString h) { _help = h;} 52 | inline StaticString key() { return _key;} 53 | inline StaticString help() { return _help;} 54 | inline Type::Value type() { return _type;} 55 | 56 | 57 | template 58 | TYPE * castAsSubType() { 59 | return (TYPE*)(this); 60 | } 61 | 62 | 63 | // positionInParent -- position (index) within parent 64 | // only applies to items within a parent (i.e. top level menu will return -1) 65 | // 0 indexed (first item has position "0") 66 | int8_t positionInParent(); 67 | 68 | protected: 69 | inline void setType(Type::Value t) { _type = t;} 70 | private: 71 | static ID id_counter; 72 | StaticStringLength stringLength(StaticString str); 73 | 74 | ID _id; 75 | ID _parentId; 76 | Type::Value _type; 77 | StaticString _key; 78 | StaticString _help; 79 | }; 80 | 81 | } 82 | } 83 | } 84 | 85 | 86 | 87 | 88 | #endif /* SERIALUIV3_SRC_INCLUDES_MENUITEM_MENUITEM_H_ */ 89 | -------------------------------------------------------------------------------- /src/includes/comm/CommChannel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * CommChannel.h 3 | * 4 | * Created on: May 27, 2018 5 | * Author: Pat Deegan 6 | * 7 | * CommChannel is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUI_SRC_INCLUDES_COMM_COMMCHANNEL_H_ 12 | #define SERIALUI_SRC_INCLUDES_COMM_COMMCHANNEL_H_ 13 | 14 | #include "../SerialUIPlatform.h" 15 | #include "CommSink.h" 16 | #include "CommSource.h" 17 | #include "../tracked/TrackedVariable.h" 18 | #include "../menuitem/items.h" 19 | #include "../auth/Authenticator.h" 20 | 21 | namespace SerialUI { 22 | namespace Comm { 23 | 24 | class Channel : public Source { 25 | public: 26 | Channel(Mode::Selection forMode); 27 | using Source::print; 28 | using Source::println; 29 | virtual size_t print(Tracked::State * state) = 0; 30 | virtual size_t print(Menu::Item::Request::Request * reqState) = 0; 31 | virtual size_t printHeading(Menu::Item::SubMenu * mnu) = 0; 32 | virtual size_t printHelpListStart(Menu::Item::SubMenu * mnu) = 0; 33 | virtual size_t printHelpListEnd(Menu::Item::SubMenu * mnu) = 0; 34 | virtual size_t printHelp(Menu::Item::Item * itm) = 0; 35 | virtual size_t printListing(Menu::Item::Item * itm) = 0; 36 | virtual void printTracked(bool force=false) = 0; 37 | virtual void showPrompt() = 0; 38 | virtual void printInputRequest(Menu::Item::Request::Request * req) = 0; 39 | virtual void printError(StaticString errMsg) = 0; 40 | inline Mode::Selection mode() { return _mode;} 41 | 42 | virtual size_t printCommandProcessingStart() = 0; 43 | virtual size_t printCommandProcessingDone() = 0; 44 | virtual uint8_t readUntilEOF(char * intoBuf, 45 | uint8_t maxLen, bool trim=false) = 0; 46 | 47 | virtual bool getBuiltinRequest(char * userString, Request * into) = 0; 48 | 49 | #ifdef SERIALUI_AUTHENTICATOR_ENABLE 50 | // Access control 51 | virtual size_t printAccessGrantRequest(Auth::Authenticator * auth) = 0; 52 | virtual size_t printAccessConfigureRequest(Auth::Authenticator * auth) = 0; 53 | #endif 54 | 55 | 56 | 57 | protected: 58 | Mode::Selection _mode; 59 | 60 | 61 | }; 62 | 63 | } /* namespace Comm */ 64 | } /* namespace SerialUI */ 65 | 66 | #endif /* SERIALUI_SRC_INCLUDES_COMM_COMMCHANNEL_H_ */ 67 | -------------------------------------------------------------------------------- /src/includes/platform/SUIPlatArduino.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SUIPlatArduino.h 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * SUIPlatArduino is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUIV3_SRC_INCLUDES_PLATFORM_SUIPLATARDUINO_H_ 12 | #define SERIALUIV3_SRC_INCLUDES_PLATFORM_SUIPLATARDUINO_H_ 13 | 14 | #include 15 | 16 | #define SERIALUI_CHANNELS_USE_STANDARDSTREAMS 17 | 18 | //define SERIALUI_AUTHENTICATOR_ENABLE 19 | 20 | #define SUI_PLATFORM_SOURCE_HASTIMEOUT_GETTERMETHOD 21 | #define SUI_PLATFORM_SOURCE_DEFAULT Serial 22 | 23 | 24 | 25 | #define SERIALUI_MENUSTRUCTURE_NUMITEMS_ATSTARTUP 15 26 | #define SERIALUI_MENUSTRUCTURE_NUMITEMS_GROWLIST 5 27 | 28 | #define SERIALUI_TRACKEDVIEW_MAXNUM_STATES 4 29 | #define SERIALUI_TRACKING_NUMITEMS_ATSTARTUP 5 30 | 31 | 32 | #define SUI_STR(...) F(__VA_ARGS__) 33 | #define SUI_PLATFORM_TIMENOW_MS() millis() 34 | #define SUI_PLATFORM_DELAY_MS(d) delay(d) 35 | 36 | namespace SerialUI { 37 | 38 | #ifdef DESKTOP_COMPILE 39 | #define SUI_FLASHSTRING const char * 40 | typedef const char * StaticString; 41 | typedef const char * DynamicString; 42 | #else 43 | #define SUI_STATICSTRING_IS_DISTINCT_TYPE 44 | #define SUI_FLASHSTRING const __FlashStringHelper* 45 | 46 | typedef const __FlashStringHelper* StaticString; 47 | typedef const char * DynamicString; 48 | #endif 49 | 50 | #ifdef SUI_STATICSTRING_IS_DISTINCT_TYPE 51 | #include 52 | #define SUI_PLATFORM_STATICSTRING_LENGTH(s) strlen_P(reinterpret_cast(s)) 53 | 54 | #else 55 | 56 | #define SUI_PLATFORM_STATICSTRING_LENGTH(s) strlen(s) 57 | #endif 58 | 59 | 60 | namespace Comm { 61 | 62 | typedef Stream SourceBase; 63 | typedef Print SinkBase; 64 | #ifdef DESKTOP_COMPILE 65 | typedef GlobalSerialWrapper SourceType; 66 | #else 67 | typedef HardwareSerial SourceType; 68 | #endif 69 | 70 | 71 | } 72 | 73 | } 74 | 75 | 76 | #ifdef SERIALUI_ENABLE_DEBUG_OUTPUT 77 | #define SERIALUI_DEBUG_OUT(...) Serial.print(__VA_ARGS__) 78 | 79 | #define SERIALUI_DEBUG_OUTLN(...) Serial.println(__VA_ARGS__) 80 | 81 | 82 | #endif /* SERIALUI_ENABLE_DEBUG_OUTPUT */ 83 | 84 | 85 | #endif /* SERIALUIV3_SRC_INCLUDES_PLATFORM_SUIPLATARDUINO_H_ */ 86 | -------------------------------------------------------------------------------- /src/includes/tracked/TrackedNum.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TrackedNum.h 3 | * 4 | * Created on: May 26, 2018 5 | * Author: Pat Deegan 6 | * 7 | * TrackedNum is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUI_SRC_INCLUDES_TRACKED_TRACKEDNUM_H_ 12 | #define SERIALUI_SRC_INCLUDES_TRACKED_TRACKEDNUM_H_ 13 | 14 | #include "TrackedVariable.h" 15 | 16 | namespace SerialUI { 17 | namespace Tracked { 18 | 19 | 20 | #define DEF_COUNTABLECLASS(name, tval, trackedType) \ 21 | class name: public StateImplCountable \ 22 | { \ 23 | public: \ 24 | name(StaticString n) : StateImplCountable(n, 0) {} \ 25 | name(StaticString n, trackedType v) : StateImplCountable(n, v) {} \ 26 | name(StaticString n, ID sid, trackedType v) : StateImplCountable(n, sid, v) {} \ 27 | using StateImplCountable::operator=; \ 28 | using StateImplCountable::operator==; \ 29 | using StateImplCountable::operator!=; \ 30 | using StateImplCountable::operator+; \ 31 | using StateImplCountable::operator-; \ 32 | using StateImplCountable::operator*; \ 33 | using StateImplCountable::operator/; \ 34 | using StateImplCountable::operator+=; \ 35 | using StateImplCountable::operator-=; \ 36 | using StateImplCountable::operator*=; \ 37 | using StateImplCountable::operator/=; \ 38 | } 39 | 40 | 41 | DEF_COUNTABLECLASS(UnsignedInteger, UInt, unsigned int); 42 | DEF_COUNTABLECLASS(Integer, Int, int); 43 | DEF_COUNTABLECLASS(Float, Float, float); 44 | DEF_COUNTABLECLASS(Character, Char, unsigned char); 45 | DEF_COUNTABLECLASS(BoundedLongInt, BoundedLongInt, long int); 46 | DEF_COUNTABLECLASS(OptionsList, BoundedLongInt, long int); 47 | DEF_COUNTABLECLASS(DateTime, DateTime, unsigned long int); 48 | DEF_COUNTABLECLASS(Time, Time, unsigned long int); 49 | DEF_COUNTABLECLASS(Event, Event, unsigned long int); 50 | 51 | 52 | } 53 | } 54 | 55 | 56 | #endif /* SERIALUI_SRC_INCLUDES_TRACKED_TRACKEDNUM_H_ */ 57 | -------------------------------------------------------------------------------- /src/includes/comm/CommFieldBoundaries.h: -------------------------------------------------------------------------------- 1 | /* 2 | * CommFieldBoundaries.h 3 | * 4 | * Created on: Sep 23, 2018 5 | * Author: Pat Deegan 6 | * 7 | * CommFieldBoundaries is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUI_SRC_INCLUDES_COMM_COMMFIELDBOUNDARIES_H_ 12 | #define SERIALUI_SRC_INCLUDES_COMM_COMMFIELDBOUNDARIES_H_ 13 | 14 | #define SERIAL_UI_PROGCHANFIELD_END 0xfe 15 | #define SERIAL_UI_PROGCHANFIELD_SEP 0xf5 16 | 17 | 18 | #define SERIAL_UI_PROGCHANFIELD_AUTHENTICATION_START 0xac 19 | #define SERIAL_UI_PROGCHANFIELD_AUTHENTICATION_SEP SERIAL_UI_PROGCHANFIELD_SEP 20 | #define SERIAL_UI_PROGCHANFIELD_AUTHENTICATION_END SERIAL_UI_PROGCHANFIELD_END 21 | 22 | 23 | 24 | #define SERIAL_UI_PROGCHANFIELD_COMMANDPROC_START 0xc0 25 | 26 | #define SERIAL_UI_PROGCHANFIELD_COMMANDPROC_END SERIAL_UI_PROGCHANFIELD_END 27 | 28 | 29 | #define SERIAL_UI_PROGCHANFIELD_MENULISTING_START 0xf0 30 | #define SERIAL_UI_PROGCHANFIELD_MENULISTING_END 0xff 31 | 32 | 33 | #define SERIAL_UI_PROGCHANFIELD_HELP_START 0xfb 34 | #define SERIAL_UI_PROGCHANFIELD_HELP_SEP 0xab 35 | #define SERIAL_UI_PROGCHANFIELD_HELP_END SERIAL_UI_PROGCHANFIELD_END 36 | 37 | #define SERIAL_UI_PROGCHANFIELD_ERROR_START 0xe0 38 | #define SERIAL_UI_PROGCHANFIELD_ERROR_END SERIAL_UI_PROGCHANFIELD_END 39 | 40 | 41 | #define SERIAL_UI_PROGCHANFIELD_ITEM_START 0xf1 42 | #define SERIAL_UI_PROGCHANFIELD_ITEM_SEP SERIAL_UI_PROGCHANFIELD_SEP 43 | #define SERIAL_UI_PROGCHANFIELD_ITEM_END SERIAL_UI_PROGCHANFIELD_END 44 | 45 | #define SERIAL_UI_PROGCHANFIELD_STATE_START 0xf2 46 | #define SERIAL_UI_PROGCHANFIELD_STATE_SEP SERIAL_UI_PROGCHANFIELD_SEP 47 | #define SERIAL_UI_PROGCHANFIELD_STATE_END SERIAL_UI_PROGCHANFIELD_END 48 | 49 | 50 | #define SERIAL_UI_PROGCHANFIELD_REQVARUPDATE_START 0xf3 51 | #define SERIAL_UI_PROGCHANFIELD_REQVARUPDATE_SEP SERIAL_UI_PROGCHANFIELD_SEP 52 | #define SERIAL_UI_PROGCHANFIELD_REQVARUPDATE_END SERIAL_UI_PROGCHANFIELD_END 53 | 54 | #define SERIAL_UI_PROGCHANREQUEST_HEADER_COMMAND 0xc0 55 | #define SERIAL_UI_PROGCHANREQUEST_HEADER_REQINPUT 0xc1 56 | #define SERIAL_UI_PROGCHANREQUEST_HEADER_SYSCOMMAND 0xc2 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | #endif /* SERIALUI_SRC_INCLUDES_COMM_COMMFIELDBOUNDARIES_H_ */ 65 | -------------------------------------------------------------------------------- /src/includes/SerialUIConfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SerialUIConfig.h 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * SerialUIConfig is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUIV3_SRC_INCLUDES_SERIALUICONFIG_H_ 12 | #define SERIALUIV3_SRC_INCLUDES_SERIALUICONFIG_H_ 13 | 14 | 15 | // SERIAL_UI_ENABLE_USBSERIAL_TERMINALACCESS 16 | // undefine this to save about 2k of flash, at the cost 17 | // of losing console/terminal access (must use device druid GUI) 18 | #define SERIAL_UI_ENABLE_USBSERIAL_TERMINALACCESS 19 | 20 | 21 | #define SERIALUI_USERCHECK_MAXDELAY_DEFAULT_MS 5000 22 | 23 | 24 | 25 | #define SERIALUI_HANDLEREQUESTS_DELAY_MS 2 26 | 27 | #define SERIALUI_USERCHECK_BLOCKFORINPUTDELAY_MS 2 28 | 29 | #define SUI_BUILTIN_REQUESTS_MAXSIZE 4 30 | 31 | 32 | /* These _DEFAULT values should be set 33 | * by platform (without the _DEFAULT suffix), 34 | * but we have sane defaults, here, used if the corresponding 35 | * setting isn't defined by the platform. 36 | */ 37 | #define SERIALUI_MENUSTRUCTURE_NUMITEMS_ATSTARTUP_DEFAULT 15 38 | #define SERIALUI_MENUSTRUCTURE_NUMITEMS_GROWLIST_DEFAULT 5 39 | #define SERIALUI_TRACKING_NUMITEMS_ATSTARTUP_DEFAULT 5 40 | #define SERIALUI_TRACKEDVIEW_MAXNUM_STATES_DEFAULT 4 41 | 42 | 43 | #define SERIALUI_LANGUAGE_EN 44 | 45 | //#define SERIALUI_BUILD_TESTS 46 | 47 | 48 | 49 | 50 | #define SERIAL_UI_VERSION 3 51 | #define SERIAL_UI_SUBVERSION 2 52 | #define SERIAL_UI_PATCHLEVEL 2 53 | 54 | 55 | 56 | #define SUIXSTR(s) SUISTR(s) 57 | #define SUISTR(s) #s 58 | 59 | 60 | #define SERIAL_UI_VERSION_TOSTRING(V, SV) V "." SV 61 | #define SERIAL_UI_VERSION_STRING SERIAL_UI_VERSION_TOSTRING(SUIXSTR(SERIAL_UI_VERSION), SUIXSTR(SERIAL_UI_SUBVERSION)) 62 | 63 | #define SERIALUI_VERSION_AT_LEAST(v, sub) ( ((SERIAL_UI_SUBVERSION >= sub) and (SERIAL_UI_VERSION >= v)) or \ 64 | (SERIAL_UI_VERSION > v)) 65 | 66 | 67 | #define SERIALUI_AUTH_PASSPHRASE_MINLEN 5 68 | #define SERIALUI_AUTH_PASSPHRASE_MAXLEN 64 69 | 70 | // #define SERIALUI_ENABLE_DEBUG_OUTPUT 71 | // #define SERIALUI_WARN_PLATFORM_DETECTION_DEBUG 72 | 73 | #endif /* SERIALUIV3_SRC_INCLUDES_SERIALUICONFIG_H_ */ 74 | -------------------------------------------------------------------------------- /src/includes/menuitem/SubMenu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SubMenu.h 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * SubMenu is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUIV3_SRC_INCLUDES_MENUITEM_SUBMENU_H_ 12 | #define SERIALUIV3_SRC_INCLUDES_MENUITEM_SUBMENU_H_ 13 | 14 | #include "../SerialUITypes.h" 15 | #include "MenuItem.h" 16 | #include "../Menu.h" 17 | 18 | 19 | namespace SerialUI { 20 | namespace Menu { 21 | namespace Item { 22 | 23 | class SubMenu : public Menu, public Item { 24 | public: 25 | SubMenu(ID parentId, StaticString key, StaticString help); 26 | SubMenu(ID id, ID parentId, StaticString key, StaticString help); 27 | 28 | virtual void call(Menu * callingMenu); // implies "entering" the submenu. 29 | 30 | virtual uint8_t numItems(); 31 | virtual Item * itemById(ID itemId); 32 | virtual Item * itemByIndex(uint8_t idx); 33 | virtual Item * itemByKey(DynamicString keyToFind); 34 | // indexForItem NOTE: -1 == NOT FOUND 35 | virtual int8_t indexForItem(ID itemId); 36 | 37 | 38 | virtual ID id() { 39 | return this->Item::id(); 40 | } 41 | 42 | SubMenu * handleRequest(); 43 | 44 | 45 | virtual void upLevel() ; 46 | virtual void outputListing() ; 47 | virtual void outputHelp() ; 48 | virtual void switchMode(Mode::Selection switchTo) ; 49 | virtual uint8_t refreshTracking(bool force=false) ; 50 | virtual void exitRequested(); 51 | 52 | virtual bool addText(StaticString title, 53 | StaticString contents=NULL); 54 | 55 | 56 | virtual bool addView(TrackedView & trackedView); 57 | 58 | virtual bool addCommand(StaticString key_str, CommandCallback callback, 59 | StaticString help_str=NULL); 60 | 61 | virtual bool addRequest(Request::Request & req); 62 | 63 | 64 | virtual Menu * subMenu(StaticString key_str, StaticString help_str=NULL); 65 | virtual Menu * addGroup(StaticString key_str, StaticString help_str=NULL); 66 | virtual Menu * addList(StaticString key_str, StaticString help_str=NULL); 67 | 68 | private: 69 | void switchModeProgram(); 70 | void switchModeUser(); 71 | 72 | bool interruptProcessingForAccessControl(); 73 | 74 | 75 | 76 | SubMenu * handleBuiltinRequest(::SerialUI::Request::BuiltIn::Selection sel); 77 | 78 | 79 | }; 80 | 81 | } /* namespace Item */ 82 | } /* namespace Menu */ 83 | } /* namespace SerialUI */ 84 | 85 | #endif /* SERIALUIV3_SRC_INCLUDES_MENUITEM_SUBMENU_H_ */ 86 | -------------------------------------------------------------------------------- /src/ItemReqBoundedLong.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ItemReqBoundedLong.cpp 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * ItemReqBoundedLong is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #include "includes/menuitem/requests/ItemReqBoundedLong.h" 12 | #include "includes/SUIGlobals.h" 13 | 14 | namespace SerialUI { 15 | namespace Menu { 16 | namespace Item { 17 | namespace Request { 18 | 19 | 20 | BoundedLong::BoundedLong(long int initVal, 21 | StaticString key, 22 | StaticString help, long int min, long int max, 23 | ValueChangedCallback vchng, 24 | ValidatorCallback validcb): 25 | COUNTABLEREQCLASS_PARENT(Type::BoundedLongInt, long int, BoundedLong) 26 | ( initVal, key, help, vchng, validcb), 27 | _minAllowed(min), _maxAllowed(max), 28 | _stepVal(1) 29 | { 30 | 31 | ensureSaneBounds(); 32 | if (initVal >= min && initVal <= max) { 33 | 34 | this->setValue(initVal); 35 | } else { 36 | 37 | this->setValue(_minAllowed); 38 | } 39 | 40 | } 41 | 42 | BoundedLong::BoundedLong( 43 | long int initVal, 44 | long int min, long int max, 45 | ValueChangedCallback vchng, 46 | ValidatorCallback validcb): 47 | COUNTABLEREQCLASS_PARENT(Type::BoundedLongInt, long int, BoundedLong)(initVal, vchng, validcb), 48 | _minAllowed(min), _maxAllowed(max), 49 | _stepVal(1) 50 | { 51 | 52 | ensureSaneBounds(); 53 | 54 | if (initVal >= min && initVal <= max) { 55 | 56 | this->setValue(initVal); 57 | } else { 58 | 59 | this->setValue(_minAllowed); 60 | } 61 | 62 | } 63 | bool BoundedLong::getValue(Menu * callingMenu, long int * v) { 64 | 65 | return Globals::commSource()->getLongIntFor(id(), v); 66 | } 67 | 68 | bool BoundedLong::valueIsValid(long int & val) { 69 | 70 | bool withinBounds = (val >= _minAllowed && val <= _maxAllowed); 71 | 72 | return withinBounds; 73 | } 74 | 75 | void BoundedLong::ensureSaneBounds() { 76 | 77 | if (_minAllowed > _maxAllowed) 78 | { 79 | long int t = _maxAllowed; 80 | _maxAllowed = _minAllowed; 81 | _minAllowed = t; 82 | } 83 | 84 | 85 | } 86 | 87 | 88 | 89 | ITEMPYTHONOVERRIDE_VALIDATION(COUNTABLEREQCLASS_PARENT(Type::BoundedLongInt, long int, BoundedLong), 90 | BoundedLong, long int); 91 | 92 | 93 | 94 | 95 | 96 | } /* namespace Request */ 97 | } /* namespace Item */ 98 | } /* namespace Menu */ 99 | } /* namespace SerialUI */ 100 | -------------------------------------------------------------------------------- /src/includes/settings/Serializer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Serializer.h 3 | * 4 | * Created on: May 1, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | #ifndef SERIALUI_SRC_INCLUDES_SETTINGS_SERIALIZER_H_ 14 | #define SERIALUI_SRC_INCLUDES_SETTINGS_SERIALIZER_H_ 15 | 16 | #include "../menuitem/items.h" 17 | #include "StateStorage.h" 18 | 19 | 20 | namespace SerialUI { 21 | namespace Settings { 22 | 23 | class Serializer { 24 | public: 25 | Serializer(Storage * store, uint16_t maxsize) ; 26 | virtual ~Serializer() {} 27 | 28 | bool store(Menu::Item::Item * item); 29 | 30 | protected: 31 | // serializerStart call once at start with top level item 32 | virtual bool serializerStart(Menu::Item::Item * item) { return true;} 33 | 34 | 35 | virtual bool serializePushParent(Menu::Item::SubMenu * itmContainer) = 0; 36 | 37 | virtual bool serialize(Menu::Item::Command * cmd) = 0; 38 | 39 | 40 | virtual bool serialize(Menu::Item::Request::Boolean * req) = 0; 41 | virtual bool serialize(Menu::Item::Request::BoundedLong * req) = 0; 42 | virtual bool serialize(Menu::Item::Request::OptionsList * req) = 0; 43 | virtual bool serialize(Menu::Item::Request::Float * req) = 0; 44 | virtual bool serialize(Menu::Item::Request::Long * req) = 0; 45 | virtual bool serialize(Menu::Item::Request::UnsignedLong * req) = 0; 46 | virtual bool serialize(Menu::Item::Request::Event * req) = 0; 47 | virtual bool serialize(Menu::Item::Request::Color * req) = 0; 48 | virtual bool serialize(Menu::Item::Request::Time * req) = 0; 49 | virtual bool serialize(Menu::Item::Request::DateTime * req) = 0; 50 | virtual bool serialize(Menu::Item::Request::Character * req) = 0; 51 | virtual bool serialize(Menu::Item::Request::String * req) = 0; 52 | 53 | 54 | virtual bool serializePopParent(Menu::Item::SubMenu * itmContainer) = 0; 55 | 56 | virtual bool serializerEnd(SerializedState into, uint16_t maxsize) = 0; 57 | 58 | 59 | private: 60 | 61 | bool serializeItem(Menu::Item::Item * item); 62 | 63 | bool serializeRequest(Menu::Item::Request::Request * req); 64 | 65 | // Menu::Item::SubMenu * menuStack[SERIALIZER_MAX_DEPTH]; 66 | Storage * _storage; 67 | uint16_t max_serstate_len; 68 | 69 | }; 70 | 71 | 72 | } /* namespace Settings */ 73 | } /* namespace SerialUI */ 74 | 75 | 76 | #endif /* SERIALUI_SRC_INCLUDES_SETTINGS_SERIALIZER_H_ */ 77 | -------------------------------------------------------------------------------- /examples/BasicUI/BasicUISettings.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _BasicUI_BasicUISettings_h 3 | #define _BasicUI_BasicUISettings_h 4 | 5 | 6 | /* 7 | * BasicUISettings.h -- part of the BasicUI project. 8 | * Hard-coded system settings, configurable through #defines 9 | * Pat Deegan 10 | * Psychogenic.com 11 | * 12 | * Copyright (C) 2019 Pat Deegan, psychogenic.com 13 | * 14 | * Generated by DruidBuilder [https://devicedruid.com/], 15 | * as part of project "f479e26ae09b4eab8cb47b1383145f81zGgk4QUJUp", 16 | * aka BasicUI. 17 | * 18 | * Druid4Arduino, Device Druid, Druid Builder, the builder 19 | * code brewery and its wizards, SerialUI and supporting 20 | * libraries, as well as the generated parts of this program 21 | * are 22 | * Copyright (C) 2013-2019 Pat Deegan 23 | * [https://psychogenic.com/ | https://inductive-kickback.com/] 24 | * and distributed under the terms of their respective licenses. 25 | * See https://devicedruid.com for details. 26 | * 27 | * 28 | * This program is distributed in the hope that it will be useful, 29 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 30 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 31 | * THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 32 | * PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, 33 | * YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR 34 | * CORRECTION. 35 | * 36 | * Keep in mind that there is no warranty and you are solely 37 | * responsible for the use of all these cool tools. 38 | * 39 | * Play safe, have fun. 40 | * 41 | */ 42 | 43 | 44 | 45 | /* Defaults should be fine, but you may set each to 46 | * something appropriate for your situation. 47 | * 48 | * Of special interest: serial_baud_rate -- this must match 49 | * what you specify while using the Druid GUI 50 | * 51 | * generated for usbserial 52 | */ 53 | 54 | // serial_baud_rate -- connect to device at this baud rate, using druid 55 | #define serial_baud_rate 57600 56 | 57 | 58 | 59 | // serial_maxidle_ms -- how long before we consider the user 60 | // gone, for lack of activity (milliseconds) 61 | #define serial_maxidle_ms 30000 62 | 63 | // serial_readtimeout_ms -- timeout when we're expecting input 64 | // for a specific request/read (milliseconds) 65 | #define serial_readtimeout_ms 20000 66 | 67 | #define serial_ui_greeting_str " BasicUI " 68 | // serial_input_terminator -- what we consider an (i.e. newline) 69 | #define serial_input_terminator '\n' 70 | 71 | // if you included requests for "strings", 72 | // request_inputstring_maxlen will set the max length allowable 73 | // (bigger need more RAM) 74 | #define request_inputstring_maxlen 50 75 | 76 | 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /src/includes/menuitem/requests/ItemReqTime.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ItemReqTime.h 3 | * 4 | * Created on: Jun 2, 2018 5 | * Author: Pat Deegan 6 | * 7 | * ItemReqTime is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUI_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQTIME_H_ 12 | #define SERIALUI_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQTIME_H_ 13 | 14 | #include "ItemReqUnsignedLong.h" 15 | namespace SerialUI { 16 | namespace Menu { 17 | namespace Item { 18 | namespace Request { 19 | 20 | class Time : public UnsignedLong { 21 | public: 22 | typedef union TimeElementsUnion { 23 | struct __attribute__((__packed__)) { 24 | uint8_t second; 25 | uint8_t minute; 26 | uint8_t hour; 27 | uint8_t reserved; 28 | }; 29 | uint32_t timeValue; 30 | TimeElementsUnion(uint32_t v=0) : 31 | timeValue(v) { 32 | 33 | } 34 | 35 | TimeElementsUnion(uint8_t h, uint8_t m, uint8_t s) : 36 | second(s < 60 ? s : 0), 37 | minute(m < 60 ? m : 0 ), 38 | hour(h < 24 ? h : 0), 39 | reserved(0) 40 | { 41 | 42 | } 43 | 44 | uint32_t daySeconds() const { 45 | return (second + (minute * 60) + (hour * 60 * 60)); 46 | } 47 | bool operator==(const TimeElementsUnion & other) { 48 | return (daySeconds() == other.daySeconds()); 49 | } 50 | inline bool operator!=(const TimeElementsUnion & other) { 51 | return (! ((*this) == other)); 52 | } 53 | bool operator<(const TimeElementsUnion & other) { 54 | return (daySeconds() < other.daySeconds()); 55 | } 56 | bool operator<=(const TimeElementsUnion & other){ 57 | return (daySeconds() <= other.daySeconds()); 58 | } 59 | inline bool operator>(const TimeElementsUnion & other) { 60 | return (! ((*this) <= other)); 61 | } 62 | inline bool operator>=(const TimeElementsUnion & other) { 63 | return (! ((*this) < other)); 64 | } 65 | 66 | } TimeElements; 67 | 68 | static TimeElements asTimeValue(uint32_t t); 69 | static uint32_t toValue(const TimeElements & te); 70 | 71 | Time(uint8_t hour, uint8_t minute, uint8_t second, 72 | StaticString key, 73 | StaticString help, 74 | ValueChangedCallback vchng=NULL, 75 | ValidatorCallback validcb=NULL); 76 | Time(unsigned long int initVal=0, ValueChangedCallback vchng=NULL, 77 | ValidatorCallback validcb=NULL); 78 | Time(unsigned long int initVal, StaticString key, 79 | StaticString help, ValueChangedCallback vchng=NULL, 80 | ValidatorCallback validcb=NULL); 81 | 82 | TimeElements timeValue(); 83 | 84 | }; 85 | 86 | } /* namespace Request */ 87 | } /* namespace Item */ 88 | } /* namespace Menu */ 89 | } /* namespace SerialUI */ 90 | 91 | #endif /* SERIALUI_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQTIME_H_ */ 92 | -------------------------------------------------------------------------------- /examples/BasicAuth/BasicAuthSettings.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _BasicAuth_BasicAuthSettings_h 3 | #define _BasicAuth_BasicAuthSettings_h 4 | 5 | 6 | /* 7 | * BasicAuthSettings.h -- part of the BasicAuth project. 8 | * Hard-coded system settings, configurable through #defines 9 | * Pat Deegan 10 | * Psychogenic.com 11 | * 12 | * Copyright (C) 2019 Pat Deegan, psychogenic.com 13 | * 14 | * Generated by DruidBuilder [https://devicedruid.com/], 15 | * as part of project "f479e26ae09b4eab8cb47b1383145f81zGgk4QUJUp", 16 | * aka BasicAuth. 17 | * 18 | * Druid4Arduino, Device Druid, Druid Builder, the builder 19 | * code brewery and its wizards, SerialUI and supporting 20 | * libraries, as well as the generated parts of this program 21 | * are 22 | * Copyright (C) 2013-2019 Pat Deegan 23 | * [https://psychogenic.com/ | https://inductive-kickback.com/] 24 | * and distributed under the terms of their respective licenses. 25 | * See https://devicedruid.com for details. 26 | * 27 | * 28 | * This program is distributed in the hope that it will be useful, 29 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 30 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 31 | * THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 32 | * PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, 33 | * YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR 34 | * CORRECTION. 35 | * 36 | * Keep in mind that there is no warranty and you are solely 37 | * responsible for the use of all these cool tools. 38 | * 39 | * Play safe, have fun. 40 | * 41 | */ 42 | 43 | 44 | 45 | /* Defaults should be fine, but you may set each to 46 | * something appropriate for your situation. 47 | * 48 | * Of special interest: serial_baud_rate -- this must match 49 | * what you specify while using the Druid GUI 50 | * 51 | * generated for usbserial 52 | */ 53 | 54 | // serial_baud_rate -- connect to device at this baud rate, using druid 55 | #define serial_baud_rate 57600 56 | 57 | 58 | 59 | // serial_maxidle_ms -- how long before we consider the user 60 | // gone, for lack of activity (milliseconds) 61 | #define serial_maxidle_ms 30000 62 | 63 | // serial_readtimeout_ms -- timeout when we're expecting input 64 | // for a specific request/read (milliseconds) 65 | #define serial_readtimeout_ms 20000 66 | 67 | #define serial_ui_greeting_str " BasicAuth " 68 | // serial_input_terminator -- what we consider an (i.e. newline) 69 | #define serial_input_terminator '\n' 70 | 71 | // if you included requests for "strings", 72 | // request_inputstring_maxlen will set the max length allowable 73 | // (bigger need more RAM) 74 | #define request_inputstring_maxlen 50 75 | 76 | 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /src/includes/GrowableList.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GrowableList.h 3 | * 4 | * Created on: May 26, 2018 5 | * Author: Pat Deegan 6 | * 7 | * GrowableList is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUI_SRC_INCLUDES_MENU_GROWABLELIST_H_ 12 | #define SERIALUI_SRC_INCLUDES_MENU_GROWABLELIST_H_ 13 | 14 | #include "SerialUIExtIncludes.h" 15 | 16 | 17 | #ifndef SERIALUI_MENUSTRUCTURE_NUMITEMS_GROWLIST 18 | #define SERIALUI_MENUSTRUCTURE_NUMITEMS_GROWLIST SERIALUI_MENUSTRUCTURE_NUMITEMS_GROWLIST_DEFAULT 19 | #endif 20 | 21 | namespace SerialUI { 22 | 23 | 24 | template 25 | class GrowableList { 26 | public: 27 | GrowableList(uint8_t numItems): 28 | _numItems(0),_maxItems(numItems), _itemsList(NULL) 29 | { 30 | _itemsList = new ITEMTYPE*[_maxItems]; 31 | for (uint8_t i = 0; i < _maxItems; i++) { 32 | _itemsList[i] = NULL; 33 | } 34 | 35 | } 36 | 37 | virtual ~GrowableList() { 38 | if (_itemsList) { 39 | delete[] _itemsList; 40 | } 41 | } 42 | 43 | bool addItem(ITEMTYPE * itm) { 44 | if (! itm) { 45 | return false; 46 | } 47 | if (_numItems >= _maxItems) { 48 | if (!growItemList()) { 49 | return false; 50 | } 51 | } 52 | 53 | 54 | _itemsList[_numItems] = itm; 55 | _numItems++; 56 | /* 57 | Serial.print(F("ADDED ITEM! NOW HAVE: ")); 58 | Serial.println(_numItems); 59 | Serial.print((int)(itm->id())); 60 | Serial.print(F(" w/par ")); 61 | Serial.println((int)(itm->parentId())); 62 | */ 63 | 64 | return true; 65 | } 66 | ITEMTYPE * getItemById(IDTYPE id) { 67 | for (uint8_t i = 0; i < _numItems; i++) { 68 | if (_itemsList[i]->id() == id) { 69 | return _itemsList[i]; 70 | } 71 | } 72 | 73 | return NULL; 74 | } 75 | 76 | ITEMTYPE * itemByIndex(uint8_t i) { return _itemsList[i];} 77 | uint8_t numItems() { return _numItems;} 78 | protected: 79 | uint8_t itemCapacity() { return _maxItems;} 80 | bool growItemList(uint8_t byAmount=5) { 81 | 82 | uint8_t newMax = _maxItems + byAmount; 83 | ITEMTYPE ** daNewList = new ITEMTYPE*[newMax]; 84 | if (!daNewList) { 85 | return false; 86 | } 87 | 88 | _maxItems = newMax; 89 | for (uint8_t i=_numItems; i<_maxItems; i++){ 90 | daNewList[i] = NULL; 91 | } 92 | 93 | for (uint8_t i = 0; i < _numItems; i++) { 94 | daNewList[i] = _itemsList[i]; 95 | } 96 | delete[] _itemsList; 97 | _itemsList = daNewList; 98 | 99 | 100 | return true; 101 | } 102 | 103 | private: 104 | uint8_t _numItems; 105 | uint8_t _maxItems; 106 | ITEMTYPE ** _itemsList; 107 | 108 | }; 109 | 110 | 111 | 112 | } /* namespace SerialUI */ 113 | 114 | 115 | 116 | #endif /* SERIALUI_SRC_INCLUDES_MENU_GROWABLELIST_H_ */ 117 | -------------------------------------------------------------------------------- /src/includes/SUIState.h: -------------------------------------------------------------------------------- 1 | /* 2 | * State.h 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * State is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUIV3_SRC_INCLUDES_STATE_H_ 12 | #define SERIALUIV3_SRC_INCLUDES_STATE_H_ 13 | 14 | #include "SerialUITypes.h" 15 | #include "menuitem/ItemCommand.h" 16 | #include "menuitem/ItemRequest.h" 17 | #include "menuitem/SubMenu.h" 18 | #include "comm/CommRequest.h" 19 | 20 | namespace SerialUI { 21 | 22 | 23 | typedef union GeneralStateFlagsU { 24 | struct { 25 | bool user_present :1; 26 | bool user_check_performed :1; 27 | bool response_transmitted :1; 28 | bool echo_commands :1; 29 | bool menu_manual_override :1; 30 | bool user_just_arrived: 1; 31 | bool always_heartbeat: 1; 32 | bool should_exit :1; 33 | }; 34 | uint8_t flags; 35 | GeneralStateFlagsU(uint8_t v) : 36 | flags(v) { 37 | } 38 | 39 | 40 | } GeneralStateFlags; 41 | 42 | class State { 43 | public: 44 | typedef enum { 45 | INVALID = 0x00, 46 | Idle = 0x01, 47 | Command = 0x02, 48 | InputRequest = 0x03, 49 | 50 | } Activity; 51 | State(); 52 | 53 | inline void setIdle() { _currentActivity = Idle;} 54 | 55 | void processingCommand(Menu::Item::Command * cmdItem); 56 | void gettingInput(Menu::Item::Request::Request * inputItem); 57 | void enterMenu(Menu::Item::SubMenu * sub); 58 | 59 | inline Activity current() { return _currentActivity;} 60 | inline Menu::Item::SubMenu * currentMenu() { return _currentMenu;} 61 | 62 | inline bool haveCurrentRequestContext() { return _currentRequestContext != NULL;} 63 | inline void setCurrentRequestContext(Comm::Request * rc) { _currentRequestContext = rc;} 64 | inline Comm::Request * currentRequestContext() { return _currentRequestContext; } 65 | inline void clearCurrentRequestContext() { _currentRequestContext = NULL; } 66 | 67 | Menu::Item::Item * currentItem() ; 68 | 69 | 70 | inline void setMode(Mode::Selection setTo) { _mode = setTo;} 71 | inline Mode::Selection mode() { return _mode;} 72 | void setGreeting(StaticString greets); 73 | StaticString greeting() { return _greetingMsg;} 74 | void setUID(StaticString u); 75 | StaticString uid() { return _uid;} 76 | 77 | GeneralStateFlags & flags() { return _stateflags;} 78 | bool userPresent() { return _stateflags.user_present;} 79 | void setShouldExit(bool setTo=true) { _stateflags.should_exit = setTo;} 80 | private: 81 | Activity _currentActivity; 82 | Menu::Item::ID _currentMenuId; 83 | Menu::Item::ID _currentItemId; 84 | Menu::Item::SubMenu * _currentMenu; 85 | Comm::Request * _currentRequestContext; 86 | Mode::Selection _mode; 87 | StaticString _greetingMsg; 88 | StaticString _uid; 89 | GeneralStateFlags _stateflags; 90 | 91 | 92 | 93 | 94 | }; 95 | 96 | } /* namespace SerialUI */ 97 | 98 | #endif /* SERIALUIV3_SRC_INCLUDES_STATE_H_ */ 99 | -------------------------------------------------------------------------------- /src/includes/platform/detect/XMegaDetection.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * XMegaDetection.h -- SovA compile time configuration. 4 | * Copyright (C) 2017 Pat Deegan. All rights reserved. 5 | * 6 | * https://devicedruid.com 7 | * https://inductive-kickback.com/projects/SerialUI 8 | * 9 | * Please let me know if you use SerialUI/SovA in your projects, and 10 | * provide a URL if you'd like me to link to it from the SovA 11 | * home. 12 | * 13 | * 14 | * This program library is free software; you can redistribute it and/or 15 | * modify it under the terms of the GNU Lesser General Public 16 | * License as published by the Free Software Foundation; either 17 | * version 3 of the License, or (at your option) any later 18 | * version. 19 | * 20 | * This program is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 23 | * 24 | * See file LICENSE.txt for further informations on licensing 25 | * terms. 26 | */ 27 | #if defined(__AVR_ATxmega16A4__) \ 28 | or defined(__AVR_ATxmega16A4U__) \ 29 | or defined(__AVR_ATxmega16C4__) \ 30 | or defined(__AVR_ATxmega16D4__) \ 31 | or defined(__AVR_ATxmega32A4__) \ 32 | or defined(__AVR_ATxmega32A4U__) \ 33 | or defined(__AVR_ATxmega32C3__) \ 34 | or defined(__AVR_ATxmega32C4__) \ 35 | or defined(__AVR_ATxmega32D3__) \ 36 | or defined(__AVR_ATxmega32D4__) \ 37 | or defined(__AVR_ATxmega8E5__) \ 38 | or defined(__AVR_ATxmega16E5__) \ 39 | or defined(__AVR_ATxmega32E5__) \ 40 | or defined(__AVR_ATxmega64A3__) \ 41 | or defined(__AVR_ATxmega64A3U__) \ 42 | or defined(__AVR_ATxmega64A4U__) \ 43 | or defined(__AVR_ATxmega64B1__) \ 44 | or defined(__AVR_ATxmega64B3__) \ 45 | or defined(__AVR_ATxmega64C3__) \ 46 | or defined(__AVR_ATxmega64D3__) \ 47 | or defined(__AVR_ATxmega64D4__) \ 48 | or defined(__AVR_ATxmega64A1__) \ 49 | or defined(__AVR_ATxmega64A1U__) \ 50 | or defined(__AVR_ATxmega128A3__) \ 51 | or defined(__AVR_ATxmega128A3U__) \ 52 | or defined(__AVR_ATxmega128B1__) \ 53 | or defined(__AVR_ATxmega128B3__) \ 54 | or defined(__AVR_ATxmega128C3__) \ 55 | or defined(__AVR_ATxmega128D3__) \ 56 | or defined(__AVR_ATxmega128D4__) \ 57 | or defined(__AVR_ATxmega192A3__) \ 58 | or defined(__AVR_ATxmega192A3U__) \ 59 | or defined(__AVR_ATxmega192C3__) \ 60 | or defined(__AVR_ATxmega192D3__) \ 61 | or defined(__AVR_ATxmega256A3__) \ 62 | or defined(__AVR_ATxmega256A3U__) \ 63 | or defined(__AVR_ATxmega256A3B__) \ 64 | or defined(__AVR_ATxmega256A3BU__) \ 65 | or defined(__AVR_ATxmega256C3__) \ 66 | or defined(__AVR_ATxmega256D3__) \ 67 | or defined(__AVR_ATxmega384C3__) \ 68 | or defined(__AVR_ATxmega384D3__) \ 69 | or defined(__AVR_ATxmega128A1__) \ 70 | or defined(__AVR_ATxmega128A1U__) \ 71 | or defined(__AVR_ATxmega128A4U__) 72 | // gots ourselves an xmega! 73 | #define SERIALUI_XMEGA_AUTODECTED 74 | #endif 75 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # GattLib++ - GATT Library C++ Wrapper 3 | # 4 | # Copyright (C) 2017 Pat Deegan, https://psychogenic.com 5 | # 6 | # 7 | # This program is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation; either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program; if not, write to the Free Software 19 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | # 21 | 22 | cmake_minimum_required(VERSION 2.6) 23 | 24 | find_package(PkgConfig REQUIRED) 25 | 26 | 27 | 28 | include_directories(. ${CMAKE_CURRENT_BINARY_DIR}) 29 | 30 | set(serialui_SRCS 31 | Authenticator.cpp 32 | AuthSimple.cpp 33 | AuthStorage.cpp 34 | AuthStoragePython.cpp 35 | AuthStorageStatic.cpp 36 | AuthValidator.cpp 37 | AuthValidatorEquality.cpp 38 | AuthValidatorPython.cpp 39 | BLESerial.cpp 40 | ChannelManager.cpp 41 | CommChannelArdStd.cpp 42 | CommChannel.cpp 43 | CommChannelSerial.cpp 44 | CommRequest.cpp 45 | CommSink.cpp 46 | CommSource.cpp 47 | DeSerializer.cpp 48 | DeSerializerJson.cpp 49 | ExternalModule.cpp 50 | ExternalPython.cpp 51 | ItemCommand.cpp 52 | ItemDynamicText.cpp 53 | ItemList.cpp 54 | ItemReqBoolean.cpp 55 | ItemReqBoundedLong.cpp 56 | ItemReqCharacter.cpp 57 | ItemReqDateTime.cpp 58 | ItemReqEvent.cpp 59 | ItemReqFloat.cpp 60 | ItemReqLong.cpp 61 | ItemReqOptions.cpp 62 | ItemReqString.cpp 63 | ItemReqTime.cpp 64 | ItemRequest.cpp 65 | ItemReqUnsignedLong.cpp 66 | ItemText.cpp 67 | ItemTrackedView.cpp 68 | LinuxBLESerial.cpp 69 | LinuxMain.cpp 70 | LinuxPrint.cpp 71 | LinuxStorageFilesystem.cpp 72 | LinuxStream.cpp 73 | Menu.cpp 74 | MenuItem.cpp 75 | MenuStructure.cpp 76 | NRF52BLESerial.cpp 77 | Serializer.cpp 78 | SerializerJson.cpp 79 | SerialUI.cpp 80 | SubGroup.cpp 81 | SubMenu.cpp 82 | SUIGlobals.cpp 83 | SUILinuxSupport.cpp 84 | SUIPlatArduino.cpp 85 | SUIPlatNRF52Arduino.cpp 86 | SUIState.cpp 87 | SUIWString.cpp 88 | TrackedString.cpp 89 | TrackedVariable.cpp 90 | Tracking.cpp ) 91 | 92 | #set(serialui_LIBS ${GOBJECT_LDFLAGS} ${GIO_LDFLAGS} ${GLIB_LDFLAGS} ${PYTHON_LDFLAGS}) 93 | set(serialui_LIBS ) 94 | 95 | add_library(serialui SHARED ${serialui_SRCS}) 96 | target_link_libraries(serialui ${serialui_LIBS}) 97 | 98 | if (SERIALUI_DEV) 99 | # forget it 100 | else() 101 | install(TARGETS serialui LIBRARY DESTINATION lib) 102 | endif() 103 | -------------------------------------------------------------------------------- /examples/Graphin/GraphinSettings.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _Graphin_GraphinSettings_h 3 | #define _Graphin_GraphinSettings_h 4 | 5 | 6 | /* 7 | * GraphinSettings.h -- part of the Graphin project. 8 | * Hard-coded system settings, configurable through #defines 9 | * Pat Deegan 10 | * Psychogenic.com 11 | * 12 | * Copyright (C) 2019 Pat Deegan, psychogenic.com 13 | * 14 | * Generated by DruidBuilder [https://devicedruid.com/], 15 | * as part of project "f1cce9edcde145b08daf90b107f23f128y5gJi5v7c", 16 | * aka Graphin. 17 | * 18 | * Druid4Arduino, Device Druid, Druid Builder, the builder 19 | * code brewery and its wizards, SerialUI and supporting 20 | * libraries, as well as the generated parts of this program 21 | * are 22 | * Copyright (C) 2013-2018 Pat Deegan 23 | * [https://psychogenic.com/ | https://flyingcarsandstuff.com/] 24 | * and distributed under the terms of their respective licenses. 25 | * See https://devicedruid.com for details. 26 | * 27 | * 28 | * This program is distributed in the hope that it will be useful, 29 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 30 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 31 | * THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 32 | * PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, 33 | * YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR 34 | * CORRECTION. 35 | * 36 | * Keep in mind that there is no warranty and you are solely 37 | * responsible for the use of all these cool tools. 38 | * 39 | * Play safe, have fun. 40 | * 41 | */ 42 | 43 | 44 | 45 | /* Defaults should be fine, but you may set each to 46 | * something appropriate for your situation. 47 | * 48 | * Of special interest: serial_baud_rate -- this must match 49 | * what you specify while using the Druid GUI 50 | * 51 | * generated for usbserial 52 | */ 53 | 54 | // serial_baud_rate -- connect to device at this baud rate, using druid 55 | #define serial_baud_rate 57600 56 | 57 | 58 | // have a "heartbeat" function to hook-up. It will be called periodically while 59 | // someone is connected... Set heartbeat_function_period_ms (millis) to specify 60 | // how often it will be called 61 | #define heartbeat_function_period_ms 1000UL 62 | 63 | 64 | // serial_maxidle_ms -- how long before we consider the user 65 | // gone, for lack of activity (milliseconds) 66 | #define serial_maxidle_ms 30000 67 | 68 | // serial_readtimeout_ms -- timeout when we're expecting input 69 | // for a specific request/read (milliseconds) 70 | #define serial_readtimeout_ms 20000 71 | 72 | #define serial_ui_greeting_str " Graphin \r\n" 73 | // serial_input_terminator -- what we consider an (i.e. newline) 74 | #define serial_input_terminator '\n' 75 | 76 | // if you included requests for "strings", 77 | // request_inputstring_maxlen will set the max length allowable 78 | // (bigger need more RAM) 79 | #define request_inputstring_maxlen 50 80 | 81 | 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /examples/AllWidgets/AllWidgetsSettings.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _AllWidgets_AllWidgetsSettings_h 3 | #define _AllWidgets_AllWidgetsSettings_h 4 | 5 | 6 | /* 7 | * AllWidgetsSettings.h -- part of the AllWidgets project. 8 | * Hard-coded system settings, configurable through #defines 9 | * Pat Deegan 10 | * Psychogenic.com 11 | * 12 | * Copyright (C) 2019 Pat Deegan 13 | * 14 | * Generated by DruidBuilder [https://devicedruid.com/], 15 | * as part of project "b4cf0e8f5cb24a839ec218119f68cfc0lEUPnNbYtz", 16 | * aka AllWidgets. 17 | * 18 | * Druid4Arduino, Device Druid, Druid Builder, the builder 19 | * code brewery and its wizards, SerialUI and supporting 20 | * libraries, as well as the generated parts of this program 21 | * are 22 | * Copyright (C) 2013-2019 Pat Deegan 23 | * [https://psychogenic.com/ | https://inductive-kickback.com/] 24 | * and distributed under the terms of their respective licenses. 25 | * See https://devicedruid.com for details. 26 | * 27 | * 28 | * This program is distributed in the hope that it will be useful, 29 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 30 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 31 | * THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 32 | * PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, 33 | * YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR 34 | * CORRECTION. 35 | * 36 | * Keep in mind that there is no warranty and you are solely 37 | * responsible for the use of all these cool tools. 38 | * 39 | * Play safe, have fun. 40 | * 41 | */ 42 | 43 | 44 | 45 | /* Defaults should be fine, but you may set each to 46 | * something appropriate for your situation. 47 | * 48 | * Of special interest: serial_baud_rate -- this must match 49 | * what you specify while using the Druid GUI 50 | * 51 | * generated for usbserial 52 | */ 53 | 54 | // serial_baud_rate -- connect to device at this baud rate, using druid 55 | #define serial_baud_rate 57600 56 | 57 | 58 | // have a "heartbeat" function to hook-up. It will be called periodically while 59 | // someone is connected... Set heartbeat_function_period_ms (millis) to specify 60 | // how often it will be called 61 | #define heartbeat_function_period_ms 2000UL 62 | 63 | 64 | // serial_maxidle_ms -- how long before we consider the user 65 | // gone, for lack of activity (milliseconds) 66 | #define serial_maxidle_ms 30000 67 | 68 | // serial_readtimeout_ms -- timeout when we're expecting input 69 | // for a specific request/read (milliseconds) 70 | #define serial_readtimeout_ms 20000 71 | 72 | #define serial_ui_greeting_str " AllWidgets " 73 | // serial_input_terminator -- what we consider an (i.e. newline) 74 | #define serial_input_terminator '\n' 75 | 76 | // if you included requests for "strings", 77 | // request_inputstring_maxlen will set the max length allowable 78 | // (bigger need more RAM) 79 | #define request_inputstring_maxlen 50 80 | 81 | 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /src/includes/platform/nrf52/BLESerial.h: -------------------------------------------------------------------------------- 1 | #ifndef SERIALUI_INTEGRATED_BLE_SERIAL_H_ 2 | #define SERIALUI_INTEGRATED_BLE_SERIAL_H_ 3 | 4 | /* 5 | * SUIBLESerial.h 6 | * from https://github.com/sandeepmistry/arduino-BLEPeripheral 7 | * slightly modified for inclusion into serialui 8 | 9 | The MIT License (MIT) 10 | 11 | Copyright (c) 2014-2016 Sandeep Mistry 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a copy 14 | of this software and associated documentation files (the "Software"), to deal 15 | in the Software without restriction, including without limitation the rights 16 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | copies of the Software, and to permit persons to whom the Software is 18 | furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included in all 21 | copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 | SOFTWARE. 30 | */ 31 | 32 | #include 33 | 34 | class SUIBLESerial : public BLEPeripheral, public Stream 35 | { 36 | public: 37 | SUIBLESerial(unsigned char req = BLE_DEFAULT_REQ, unsigned char rdy = BLE_DEFAULT_RDY, unsigned char rst = BLE_DEFAULT_RST); 38 | 39 | void begin(...); 40 | void poll(); 41 | void end(); 42 | 43 | virtual int available(void); 44 | virtual int peek(void); 45 | virtual int read(void); 46 | virtual void flush(void); 47 | virtual size_t write(uint8_t byte); 48 | using Print::write; 49 | virtual operator bool(); 50 | 51 | private: 52 | unsigned long _flushed; 53 | static SUIBLESerial* _instance; 54 | 55 | size_t _rxHead; 56 | size_t _rxTail; 57 | size_t _rxCount() const; 58 | uint8_t _rxBuffer[BLE_ATTRIBUTE_MAX_VALUE_LENGTH]; 59 | size_t _txCount; 60 | uint8_t _txBuffer[BLE_ATTRIBUTE_MAX_VALUE_LENGTH]; 61 | 62 | BLEService _uartService = BLEService("6E400001-B5A3-F393-E0A9-E50E24DCCA9E"); 63 | BLEDescriptor _uartNameDescriptor = BLEDescriptor("2901", "UART"); 64 | BLECharacteristic _rxCharacteristic = BLECharacteristic("6E400002-B5A3-F393-E0A9-E50E24DCCA9E", BLEWriteWithoutResponse, BLE_ATTRIBUTE_MAX_VALUE_LENGTH); 65 | BLEDescriptor _rxNameDescriptor = BLEDescriptor("2901", "RX - Receive Data (Write)"); 66 | BLECharacteristic _txCharacteristic = BLECharacteristic("6E400003-B5A3-F393-E0A9-E50E24DCCA9E", BLENotify, BLE_ATTRIBUTE_MAX_VALUE_LENGTH); 67 | BLEDescriptor _txNameDescriptor = BLEDescriptor("2901", "TX - Transfer Data (Notify)"); 68 | 69 | void _received(const uint8_t* data, size_t size); 70 | static void _received(BLECentral& /*central*/, BLECharacteristic& rxCharacteristic); 71 | }; 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /src/ItemReqOptions.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ItemReqOptions.cpp 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * ItemReqOptions is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #include "includes/menuitem/requests/ItemReqOptions.h" 12 | 13 | namespace SerialUI { 14 | namespace Menu { 15 | namespace Item { 16 | namespace Request { 17 | 18 | OptionsList::OptionsList(long int initVal, StaticString key, 19 | StaticString help, 20 | StaticString opt1, 21 | StaticString opt2, 22 | StaticString opt3, 23 | StaticString opt4, 24 | StaticString opt5, 25 | StaticString opt6, 26 | ValueChangedCallback vchng, 27 | ValidatorCallback validcb) : 28 | BoundedLong(initVal, key, help, 1, 2, vchng, validcb), 29 | opts(NULL), _numOptions(2) 30 | 31 | { 32 | 33 | setRequestType(Type::OptionsList); 34 | doInit(opt1,opt2,opt3,opt4,opt5,opt6); 35 | 36 | } 37 | 38 | 39 | OptionsList::OptionsList(long int initVal, ValueChangedCallback vchng, 40 | ValidatorCallback validcb) : 41 | BoundedLong(initVal, 1, 2, vchng, validcb), 42 | opts(NULL), _numOptions(0) 43 | { 44 | 45 | } 46 | 47 | 48 | void OptionsList::doInit(StaticString opt1, 49 | StaticString opt2, 50 | StaticString opt3, 51 | StaticString opt4, 52 | StaticString opt5, 53 | StaticString opt6) { 54 | uint8_t numOpts = 2; 55 | 56 | StaticString daStrings[6] = { 57 | opt1, 58 | opt2, 59 | opt3, 60 | opt4, 61 | opt5, 62 | opt6 63 | }; 64 | 65 | if (opt6 != NULL) { 66 | numOpts = 6; 67 | } else if (opt5 != NULL) { 68 | numOpts = 5; 69 | } else if (opt4 != NULL) { 70 | numOpts = 4; 71 | }else if (opt3 != NULL) { 72 | numOpts = 3; 73 | } 74 | 75 | _numOptions = numOpts; 76 | if (opts) { 77 | delete [] opts; 78 | } 79 | opts = new StaticString[numOpts]; 80 | memcpy(opts, daStrings, (numOpts * sizeof(StaticString))); 81 | 82 | setMaximum(numOpts); 83 | 84 | if (! this->valueIsValid(this->currentValue())) 85 | { 86 | this->setValue(1); 87 | } 88 | } 89 | 90 | 91 | 92 | void OptionsList::setOptions( 93 | StaticString opt1, 94 | StaticString opt2, 95 | StaticString opt3, 96 | StaticString opt4, 97 | StaticString opt5, 98 | StaticString opt6) { 99 | 100 | _numOptions = 2; 101 | doInit(opt1, opt2, opt3, opt4, opt5, opt6); 102 | } 103 | void OptionsList::freeResources() { 104 | 105 | this->BoundedLong::freeResources(); 106 | 107 | if (opts) { 108 | delete [] opts; 109 | opts = NULL; 110 | } 111 | } 112 | 113 | StaticString OptionsList::currentSelection() { 114 | return optionBySelection(this->currentValue()); 115 | } 116 | 117 | StaticString OptionsList::optionBySelection(uint8_t idx) { 118 | if (idx < 1){ 119 | return NULL; 120 | } 121 | return opts[idx - 1]; 122 | } 123 | 124 | StaticString OptionsList::optionByIndex(uint8_t idx) { 125 | if (idx >= maximum()){ 126 | return NULL; 127 | } 128 | return opts[idx]; 129 | } 130 | 131 | } /* namespace Request */ 132 | } /* namespace Item */ 133 | } /* namespace Menu */ 134 | } /* namespace SerialUI */ 135 | -------------------------------------------------------------------------------- /src/MenuStructure.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MenuStructure.cpp 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * MenuStructure is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #include "includes/menu/MenuStructure.h" 12 | 13 | namespace SerialUI { 14 | namespace Menu { 15 | 16 | Structure::Structure(uint8_t numItems) : 17 | GrowableList(numItems), 18 | _topLevel(1, 0, SUI_STR("TOP"), SUI_STR("Main Menu")) 19 | { 20 | this->addItem(&_topLevel); 21 | } 22 | 23 | 24 | 25 | uint8_t Structure::numItemsWithParent(Item::ID parentId) { 26 | uint8_t numCount = 0; 27 | /* 28 | Serial.print(F("num w/par ")); 29 | Serial.print((int)parentId); 30 | Serial.print(F("? (")); 31 | */ 32 | for (uint8_t i = 0; i < numItems(); i++) { 33 | 34 | /* 35 | uint8_t pid = itemByIndex(i)->parentId(); 36 | 37 | Serial.print((int)pid); 38 | */ 39 | if (itemByIndex(i)->parentId() == parentId) { 40 | numCount++; 41 | } 42 | } 43 | return numCount; 44 | } 45 | 46 | Item::Item * Structure::itemById(Item::ID itemId) { 47 | for (uint8_t i=0; i< numItems(); i++ ) { 48 | if (itemByIndex(i)->id() == itemId) { 49 | return itemByIndex(i); 50 | } 51 | } 52 | 53 | return NULL; 54 | } 55 | int8_t Structure::indexForItemWithParent(Item::ID parentId, Item::ID targetItemId) { 56 | int8_t numCount = 0; 57 | 58 | for (uint8_t i = 0; i < numItems(); i++) { 59 | Item::Item * itm = itemByIndex(i); 60 | if (itm->parentId() == parentId) { 61 | if (itm->id() == targetItemId) { 62 | return numCount; 63 | } 64 | numCount++; 65 | } 66 | } 67 | 68 | // Not Found 69 | return -1; 70 | } 71 | Item::Item * Structure::itemByParentAndIndex(Item::ID parentId, uint8_t idx) { 72 | 73 | 74 | uint8_t numCount = 0; 75 | /* 76 | Serial.print(F("itemByParentAndIndex looking for ")); 77 | Serial.print((int)parentId); 78 | Serial.print('/'); 79 | Serial.println((int)idx); 80 | */ 81 | for (uint8_t i = 0; i < numItems(); i++) { 82 | // Serial.print(F("itemByParentAndIndex -- checking itm #")); 83 | // Serial.println((int)i); 84 | if (itemByIndex(i)->parentId() == parentId) { 85 | // Serial.println(F("RIGHT PAR...")); 86 | if (numCount == idx) { 87 | // Serial.println(F("HUZZAH")); 88 | return itemByIndex(i); 89 | } 90 | numCount++; 91 | } 92 | } 93 | 94 | // Serial.println(F("NOGO")); 95 | return NULL; 96 | 97 | } 98 | 99 | Item::Item * Structure::itemByKey(DynamicString aKey, bool allowPartialMatch) { 100 | 101 | for (uint8_t i = 0; i < numItems(); i++) { 102 | Item::Item * itm = itemByIndex(i); 103 | if (staticStringMatch(itm->key(), aKey, allowPartialMatch)) { 104 | return itm; 105 | } 106 | } 107 | 108 | return NULL; 109 | } 110 | Item::Item * Structure::itemByParentAndKey(Item::ID parentId, 111 | DynamicString aKey, bool allowPartialMatch) { 112 | 113 | for (uint8_t i = 0; i < numItems(); i++) { 114 | Item::Item * itm = itemByIndex(i); 115 | if (itm->parentId() == parentId) { 116 | if (staticStringMatch(itm->key(), aKey, allowPartialMatch)) { 117 | return itm; 118 | } 119 | } 120 | } 121 | 122 | return NULL; 123 | } 124 | 125 | } /* namespace Menu */ 126 | } /* namespace SerialUI */ 127 | -------------------------------------------------------------------------------- /src/TrackedString.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * TrackedString.cpp 3 | * 4 | * Created on: May 26, 2018 5 | * Author: Pat Deegan 6 | * 7 | * TrackedString is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #include "includes/tracked/TrackedString.h" 12 | 13 | namespace SerialUI { 14 | namespace Tracked { 15 | 16 | 17 | String& String::operator+= (TopLevelString v) { 18 | TopLevelString o = this->value; 19 | o += v; 20 | this->assign(o); 21 | return *this; 22 | } 23 | String String::operator+(const TopLevelString& b) const { 24 | TopLevelString nstr = this->value + b; 25 | return String(this->name(), nstr); 26 | } 27 | 28 | 29 | String& String::operator= (const char *cstr) { 30 | TopLevelString s(cstr); 31 | 32 | this->assign(s); 33 | return *this; 34 | } 35 | String & String::operator += (const char *cstr) { 36 | TopLevelString s( this->value ); 37 | s += cstr; 38 | this->assign(s); 39 | return *this; 40 | } 41 | String & String::operator += (char c) { 42 | TopLevelString s( this->value ); 43 | s += c; 44 | this->assign(s); 45 | return *this; 46 | } 47 | String & String::operator += (unsigned char num) { 48 | TopLevelString s( this->value ); 49 | s += num; 50 | this->assign(s); 51 | return *this; 52 | } 53 | String & String::operator += (int num) { 54 | TopLevelString s( this->value ); 55 | s += num; 56 | this->assign(s); 57 | return *this; 58 | } 59 | String & String::operator += (unsigned int num) { 60 | TopLevelString s( this->value ); 61 | s += num; 62 | this->assign(s); 63 | return *this; 64 | } 65 | String & String::operator += (long num) { 66 | TopLevelString s( this->value ); 67 | s += num; 68 | this->assign(s); 69 | return *this; 70 | } 71 | String & String::operator += (unsigned long num) { 72 | TopLevelString s( this->value ); 73 | s += num; 74 | this->assign(s); 75 | return *this; 76 | } 77 | String & String::operator += (float num) { 78 | TopLevelString s( this->value ); 79 | s += num; 80 | this->assign(s); 81 | return *this; 82 | } 83 | String & String::operator += (double num) { 84 | TopLevelString s( this->value ); 85 | s += num; 86 | this->assign(s); 87 | return *this; 88 | } 89 | char String::operator [] (unsigned int index) const { 90 | return this->value[index]; 91 | } 92 | char& String::operator [] (unsigned int index) { 93 | char & c = this->value[index]; 94 | this->markAsChanged(); 95 | return c; 96 | } 97 | 98 | 99 | 100 | #ifndef DESKTOP_COMPILE 101 | // very arduino-specific 102 | char String::charAt(unsigned int index) const { 103 | return this->value.charAt(index); 104 | } 105 | void String::setCharAt(unsigned int index, char c) { 106 | this->value.setCharAt(index, c); 107 | this->markAsChanged(); 108 | } 109 | 110 | // parsing/conversion 111 | long String::toInt(void) const { 112 | return this->value.toInt(); 113 | } 114 | float String::toFloat(void) const { 115 | return this->value.toFloat(); 116 | } 117 | double String::toDouble(void) const { 118 | #ifdef SERIALUI_PLATFORM_NRF52 119 | #warning "no WString toDouble() on platform -- returning float instead" 120 | return this->value.toFloat(); 121 | #else 122 | return this->value.toDouble(); 123 | #endif 124 | } 125 | 126 | #endif 127 | 128 | } /* namespace Tracked */ 129 | } /* namespace SerialUI */ 130 | -------------------------------------------------------------------------------- /src/includes/platform/linux/LinuxPrint.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LinuxPrint.h 3 | * 4 | * Created on: Apr 27, 2019 5 | * Author: Pat Deegan 6 | * 7 | * Part of the SerialUI project. 8 | * Copyright (C) 2019 Pat Deegan, https://psychogenic.com 9 | * More information on licensing and usage at 10 | * https://devicedruid.com/ 11 | */ 12 | 13 | #ifndef SERIALUI_SRC_INCLUDES_PLATFORM_LINUX_LINUXPRINT_H_ 14 | #define SERIALUI_SRC_INCLUDES_PLATFORM_LINUX_LINUXPRINT_H_ 15 | 16 | 17 | /* 18 | Print.h - Base class that provides print() and println() 19 | Copyright (c) 2008 David A. Mellis. All right reserved. 20 | 21 | This library is free software; you can redistribute it and/or 22 | modify it under the terms of the GNU Lesser General Public 23 | License as published by the Free Software Foundation; either 24 | version 2.1 of the License, or (at your option) any later version. 25 | 26 | This library is distributed in the hope that it will be useful, 27 | but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | Lesser General Public License for more details. 30 | 31 | You should have received a copy of the GNU Lesser General Public 32 | License along with this library; if not, write to the Free Software 33 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 34 | */ 35 | 36 | #include "../SUIWString.h" 37 | #include "LinuxExtIncludes.h" 38 | // typedef std::string String; 39 | 40 | 41 | #define DEC 10 42 | #define HEX 16 43 | #define OCT 8 44 | #define BIN 2 45 | 46 | class Print 47 | { 48 | private: 49 | int write_error; 50 | size_t printNumber(unsigned long, uint8_t); 51 | size_t printFloat(double, uint8_t); 52 | protected: 53 | void setWriteError(int err = 1) { write_error = err; } 54 | public: 55 | Print() : write_error(0) {} 56 | virtual ~Print() {} 57 | 58 | int getWriteError() { return write_error; } 59 | void clearWriteError() { setWriteError(0); } 60 | 61 | virtual size_t write(uint8_t) = 0; 62 | size_t write(const char *str) { 63 | if (str == NULL) return 0; 64 | return write((const uint8_t *)str, strlen(str)); 65 | } 66 | virtual size_t write(const uint8_t *buffer, size_t size); 67 | 68 | // size_t print(const __FlashStringHelper *); 69 | size_t print(const String &); 70 | size_t print(const char[]); 71 | // size_t print(const char *); 72 | size_t print(char); 73 | size_t print(unsigned char, int = DEC); 74 | size_t print(int, int = DEC); 75 | size_t print(unsigned int, int = DEC); 76 | size_t print(long, int = DEC); 77 | size_t print(unsigned long, int = DEC); 78 | size_t print(double, int = 2); 79 | // size_t print(const Printable&); 80 | 81 | // size_t println(const __FlashStringHelper *); 82 | size_t println(const String &s); 83 | size_t println(const char[]); 84 | // size_t println(const char *); 85 | size_t println(char); 86 | size_t println(unsigned char, int = DEC); 87 | size_t println(int, int = DEC); 88 | size_t println(unsigned int, int = DEC); 89 | size_t println(long, int = DEC); 90 | size_t println(unsigned long, int = DEC); 91 | size_t println(double, int = 2); 92 | // size_t println(const Printable&); 93 | size_t println(void); 94 | }; 95 | 96 | 97 | 98 | #endif /* SERIALUI_SRC_INCLUDES_PLATFORM_LINUX_LINUXPRINT_H_ */ 99 | -------------------------------------------------------------------------------- /src/includes/menuitem/requests/ItemReqEvent.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ItemReqEvent.h 3 | * 4 | * Created on: Jun 2, 2018 5 | * Author: Pat Deegan 6 | * 7 | * ItemReqEvent is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUI_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQEVENT_H_ 12 | #define SERIALUI_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQEVENT_H_ 13 | 14 | #include "ItemReqUnsignedLong.h" 15 | namespace SerialUI { 16 | namespace Menu { 17 | namespace Item { 18 | namespace Request { 19 | 20 | class Event : public UnsignedLong { 21 | public: 22 | 23 | typedef union EventTimeRangeUnion { 24 | struct __attribute__((__packed__)) { 25 | uint8_t startSecond:6; 26 | uint8_t startMinute:6; 27 | uint8_t startHour:5; 28 | uint8_t endMinute:6; 29 | uint8_t endHour:5; 30 | Weekday::day day:3; 31 | bool flag:1; 32 | }; 33 | uint32_t timeValue; 34 | EventTimeRangeUnion(uint32_t v=0) : 35 | timeValue(v) { 36 | 37 | } 38 | EventTimeRangeUnion(uint8_t start_hour, uint8_t start_minute, 39 | uint8_t start_seconds, uint16_t durationMinutes=1) { 40 | startHour = start_hour < 24 ? start_hour : 23; 41 | startMinute = start_minute < 60 ? start_minute : 59; 42 | startSecond = start_seconds < 60 ? start_seconds : 59; 43 | 44 | uint16_t endTimeMinutes = (startHour * 60) + startMinute + durationMinutes; 45 | endHour = (uint8_t) ( endTimeMinutes/ 60 ); 46 | endMinute = endTimeMinutes - (60 * endHour); 47 | 48 | 49 | } 50 | EventTimeRangeUnion(uint8_t start_hour, uint8_t start_minute, 51 | uint8_t start_seconds, uint8_t end_hour, uint8_t end_minute) { 52 | 53 | startHour = start_hour < 24 ? start_hour : 23; 54 | startMinute = start_minute < 60 ? start_minute : 59; 55 | startSecond = start_seconds < 60 ? start_seconds : 59; 56 | endHour = end_hour < 24 ? end_hour : 23; 57 | endMinute = end_minute < 60 ? end_minute : 59; 58 | 59 | 60 | } 61 | uint32_t daySecondsStart() const { 62 | return (startSecond + (startMinute * 60) + (startHour * 60 *60)); 63 | } 64 | 65 | uint32_t daySecondsEnd() const { 66 | return ((endHour * 60 * 60) + (endMinute * 60)); 67 | } 68 | 69 | bool isValid() const { 70 | return (daySecondsEnd() > daySecondsStart()); 71 | } 72 | 73 | uint32_t durationSeconds() const { 74 | return (daySecondsEnd() - daySecondsStart()); 75 | } 76 | 77 | } TimeElements; 78 | 79 | static TimeElements asTimeValue(uint32_t t); 80 | static uint32_t toValue(const TimeElements & te); 81 | 82 | Event(unsigned long int initVal=0, ValueChangedCallback vchng=NULL, 83 | ValidatorCallback validcb=NULL); 84 | Event(unsigned long int initVal, StaticString key, 85 | StaticString help, ValueChangedCallback vchng=NULL, 86 | ValidatorCallback validcb=NULL); 87 | 88 | Event(uint8_t startHour, uint8_t startMinute, uint8_t startSeconds, 89 | uint16_t durationMinutes, 90 | StaticString key, 91 | StaticString help, 92 | ValueChangedCallback vchng=NULL, 93 | ValidatorCallback validcb=NULL); 94 | 95 | void setAt(const TimeElements & te); 96 | void setDay(Weekday::day day); 97 | void setStart(uint8_t hour, uint8_t minute, uint8_t seconds=0); 98 | TimeElements timeValue(); 99 | 100 | }; 101 | 102 | } /* namespace Request */ 103 | } /* namespace Item */ 104 | } /* namespace Menu */ 105 | } /* namespace SerialUI */ 106 | 107 | #endif /* SERIALUI_SRC_INCLUDES_MENUITEM_REQUESTS_ITEMREQEVENT_H_ */ 108 | -------------------------------------------------------------------------------- /src/includes/menu/MenuStructure.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MenuStructure.h 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * MenuStructure is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUIV3_SRC_INCLUDES_MENU_MENUSTRUCTURE_H_ 12 | #define SERIALUIV3_SRC_INCLUDES_MENU_MENUSTRUCTURE_H_ 13 | 14 | #include "../Menu.h" 15 | #include "../menuitem/SubMenu.h" 16 | #include "../menuitem/SubGroup.h" 17 | #include "../menuitem/ItemList.h" 18 | #include "../menuitem/ItemCommand.h" 19 | #include "../menuitem/requests/requests.h" 20 | #include "../SerialUIConfig.h" 21 | #include "../GrowableList.h" 22 | 23 | #ifndef SERIALUI_MENUSTRUCTURE_NUMITEMS_ATSTARTUP 24 | #define SERIALUI_MENUSTRUCTURE_NUMITEMS_ATSTARTUP SERIALUI_MENUSTRUCTURE_NUMITEMS_ATSTARTUP_DEFAULT 25 | #endif 26 | 27 | 28 | namespace SerialUI { 29 | namespace Menu { 30 | 31 | class Structure : public GrowableList{ 32 | public: 33 | Structure(uint8_t numItems=SERIALUI_MENUSTRUCTURE_NUMITEMS_ATSTARTUP); 34 | 35 | uint8_t numItemsWithParent(Item::ID parentId); 36 | Item::Item * itemById(Item::ID itemId); 37 | Item::Item * itemByParentAndIndex(Item::ID parentId, uint8_t idx); 38 | Item::Item * itemByParentAndKey(Item::ID parentId, 39 | DynamicString aKey, bool allowPartialMatch=true); 40 | Item::Item * itemByKey(DynamicString aKey, bool allowPartialMatch=false); 41 | Item::SubMenu * topLevelMenu() { return &(_topLevel);} 42 | 43 | int8_t indexForItemWithParent(Item::ID parentId, Item::ID targetItemId) ; 44 | 45 | template 46 | TYPE * getItemByIdCast(Item::ID id) { 47 | Item::Item * itm = this->getItemById(id); 48 | if (! itm) { 49 | return NULL; 50 | } 51 | if (itm->type() != TYPENAME) { 52 | return NULL; 53 | } 54 | return (TYPE*)itm; 55 | } 56 | 57 | #if 0 58 | NOT USEFUL? 59 | Item::SubMenu * getItemContainerById(Item::ID id) { 60 | Item::Item * itm = this->getItemById(id); 61 | if (! itm) { 62 | return NULL; 63 | } 64 | switch(itm->type()) { 65 | case Item::Type::Menu: 66 | /* fall-through */ 67 | case Item::Type::Group: 68 | /* fall-through */ 69 | case Item::Type::List: 70 | return (Item::SubMenu*)itm; 71 | default: 72 | break; 73 | } 74 | return NULL; 75 | } 76 | #endif 77 | 78 | inline Item::SubMenu * getSubMenuById(Item::ID id) { 79 | return this->getItemByIdCast(id); 80 | } 81 | 82 | inline Item::Group * getGroupById(Item::ID id) { 83 | return this->getItemByIdCast(id); 84 | } 85 | 86 | inline Item::List * getListById(Item::ID id) { 87 | return this->getItemByIdCast(id); 88 | } 89 | inline Item::Command * getCommandById(Item::ID id) { 90 | return this->getItemByIdCast(id); 91 | } 92 | 93 | inline Item::SubMenu * getItemContainerById(Item::ID id) { 94 | Item::SubMenu * cont = getSubMenuById(id); 95 | if (! cont) { 96 | cont = getGroupById(id); 97 | if (! cont) { 98 | cont = getListById(id); 99 | } 100 | } 101 | return cont; 102 | } 103 | 104 | inline Item::Request::Request * getRequestById(Item::ID id) { 105 | return this->getItemByIdCast(id); 106 | } 107 | 108 | private: 109 | 110 | Item::SubMenu _topLevel; 111 | 112 | }; 113 | 114 | } /* namespace Menu */ 115 | } /* namespace SerialUI */ 116 | 117 | #endif /* SERIALUIV3_SRC_INCLUDES_MENU_MENUSTRUCTURE_H_ */ 118 | -------------------------------------------------------------------------------- /examples/BasicUI/BasicUI.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _BasicUI_BasicUI_h 3 | #define _BasicUI_BasicUI_h 4 | 5 | 6 | /* 7 | * BasicUI.h -- part of the BasicUI project. 8 | * Declarations for everything that was generated... 9 | * Pat Deegan 10 | * Psychogenic.com 11 | * 12 | * Copyright (C) 2019 Pat Deegan, psychogenic.com 13 | * 14 | * Generated by DruidBuilder [https://devicedruid.com/], 15 | * as part of project "f479e26ae09b4eab8cb47b1383145f81zGgk4QUJUp", 16 | * aka BasicUI. 17 | * 18 | * Druid4Arduino, Device Druid, Druid Builder, the builder 19 | * code brewery and its wizards, SerialUI and supporting 20 | * libraries, as well as the generated parts of this program 21 | * are 22 | * Copyright (C) 2013-2019 Pat Deegan 23 | * [https://psychogenic.com/ | https://inductive-kickback.com/] 24 | * and distributed under the terms of their respective licenses. 25 | * See https://devicedruid.com for details. 26 | * 27 | * 28 | * This program is distributed in the hope that it will be useful, 29 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 30 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 31 | * THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 32 | * PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, 33 | * YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR 34 | * CORRECTION. 35 | * 36 | * Keep in mind that there is no warranty and you are solely 37 | * responsible for the use of all these cool tools. 38 | * 39 | * Play safe, have fun. 40 | * 41 | */ 42 | 43 | 44 | 45 | /* we need the SerialUI lib */ 46 | #include 47 | 48 | 49 | /* MySUI 50 | * Our SerialUI Instance, through which we can send/receive 51 | * data from users. 52 | */ 53 | extern SUI::SerialUI MySUI; 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | /* ********* callbacks and validation functions ********* */ 64 | 65 | 66 | 67 | /* *** Main Menu *** */ 68 | namespace MainMenu { 69 | 70 | void doClickMe(); 71 | 72 | void YesOrNoChanged(); 73 | 74 | void LimitedChoiceChanged(); 75 | 76 | void NameChanged(); 77 | 78 | void OptionsChanged(); 79 | 80 | 81 | 82 | /* *** Main Menu -> sub menu *** */ 83 | namespace SubMenu { 84 | 85 | void WhenChanged(); 86 | 87 | void doAnotherCommand(); 88 | 89 | } /* namespace SubMenu */ 90 | 91 | } /* namespace MainMenu */ 92 | 93 | 94 | 95 | 96 | 97 | /* 98 | * The container for MyInputs, which 99 | * holds all the variables for the various inputs. 100 | */ 101 | typedef struct MyInputsContainerStruct { 102 | 103 | SerialUI::Menu::Item::Request::Event When; 104 | SerialUI::Menu::Item::Request::Toggle YesOrNo; 105 | SerialUI::Menu::Item::Request::BoundedLong LimitedChoice; 106 | SerialUI::Menu::Item::Request::String Name; 107 | SerialUI::Menu::Item::Request::OptionsList Options; 108 | // constructor to set sane startup vals 109 | MyInputsContainerStruct() : 110 | When(18 /*start hour*/, 0 /*min*/, 0 /*sec*/, 120 /*num mins*/ ,SUI_STR("When"),SUI_STR("an event"),MainMenu::SubMenu::WhenChanged), 111 | YesOrNo(false,SUI_STR("Yes Or No"),SUI_STR("A boolean toggle"),MainMenu::YesOrNoChanged), 112 | LimitedChoice(0,SUI_STR("Limited Choice"),SUI_STR("A range of available values"),1,50,MainMenu::LimitedChoiceChanged), 113 | Name("",SUI_STR("Name"),SUI_STR("a text string"),request_inputstring_maxlen,MainMenu::NameChanged), 114 | Options(1,SUI_STR("Options"),SUI_STR("Choose one of these"),SUI_STR("A"),SUI_STR("B"),SUI_STR("or C"),NULL,NULL,NULL,MainMenu::OptionsChanged) 115 | {} 116 | } MyInputsContainerSt; 117 | 118 | extern MyInputsContainerSt MyInputs; 119 | 120 | 121 | 122 | 123 | 124 | /* ***** SetupSerialUI: where we'll be setting up menus and such **** */ 125 | bool SetupSerialUI(); 126 | 127 | 128 | #define DIE_HORRIBLY(msg) for(;;){ MySUI.println(msg); delay(1000); } 129 | 130 | 131 | #endif 132 | -------------------------------------------------------------------------------- /examples/BasicAuth/BasicAuth.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _BasicAuth_BasicAuth_h 3 | #define _BasicAuth_BasicAuth_h 4 | 5 | 6 | /* 7 | * BasicAuth.h -- part of the BasicAuth project. 8 | * Declarations for everything that was generated... 9 | * Pat Deegan 10 | * Psychogenic.com 11 | * 12 | * Copyright (C) 2019 Pat Deegan, psychogenic.com 13 | * 14 | * Generated by DruidBuilder [https://devicedruid.com/], 15 | * as part of project "f479e26ae09b4eab8cb47b1383145f81zGgk4QUJUp", 16 | * aka BasicAuth. 17 | * 18 | * Druid4Arduino, Device Druid, Druid Builder, the builder 19 | * code brewery and its wizards, SerialUI and supporting 20 | * libraries, as well as the generated parts of this program 21 | * are 22 | * Copyright (C) 2013-2019 Pat Deegan 23 | * [https://psychogenic.com/ | https://inductive-kickback.com/] 24 | * and distributed under the terms of their respective licenses. 25 | * See https://devicedruid.com for details. 26 | * 27 | * 28 | * This program is distributed in the hope that it will be useful, 29 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 30 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 31 | * THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 32 | * PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, 33 | * YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR 34 | * CORRECTION. 35 | * 36 | * Keep in mind that there is no warranty and you are solely 37 | * responsible for the use of all these cool tools. 38 | * 39 | * Play safe, have fun. 40 | * 41 | */ 42 | 43 | 44 | 45 | /* we need the SerialUI lib */ 46 | #include 47 | 48 | 49 | /* MySUI 50 | * Our SerialUI Instance, through which we can send/receive 51 | * data from users. 52 | */ 53 | extern SUI::SerialUI MySUI; 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | /* ********* callbacks and validation functions ********* */ 64 | 65 | 66 | 67 | /* *** Main Menu *** */ 68 | namespace MainMenu { 69 | 70 | void doClickMe(); 71 | 72 | void YesOrNoChanged(); 73 | 74 | void LimitedChoiceChanged(); 75 | 76 | void NameChanged(); 77 | 78 | void OptionsChanged(); 79 | 80 | 81 | 82 | /* *** Main Menu -> sub menu *** */ 83 | namespace SubMenu { 84 | 85 | void WhenChanged(); 86 | 87 | void doAnotherCommand(); 88 | 89 | } /* namespace SubMenu */ 90 | 91 | } /* namespace MainMenu */ 92 | 93 | 94 | 95 | 96 | 97 | /* 98 | * The container for MyInputs, which 99 | * holds all the variables for the various inputs. 100 | */ 101 | typedef struct MyInputsContainerStruct { 102 | 103 | SerialUI::Menu::Item::Request::Event When; 104 | SerialUI::Menu::Item::Request::Toggle YesOrNo; 105 | SerialUI::Menu::Item::Request::BoundedLong LimitedChoice; 106 | SerialUI::Menu::Item::Request::String Name; 107 | SerialUI::Menu::Item::Request::OptionsList Options; 108 | // constructor to set sane startup vals 109 | MyInputsContainerStruct() : 110 | When(18 /*start hour*/, 0 /*min*/, 0 /*sec*/, 120 /*num mins*/ ,SUI_STR("When"),SUI_STR("an event"),MainMenu::SubMenu::WhenChanged), 111 | YesOrNo(false,SUI_STR("Yes Or No"),SUI_STR("A boolean toggle"),MainMenu::YesOrNoChanged), 112 | LimitedChoice(0,SUI_STR("Limited Choice"),SUI_STR("A range of available values"),1,50,MainMenu::LimitedChoiceChanged), 113 | Name("",SUI_STR("Name"),SUI_STR("a text string"),request_inputstring_maxlen,MainMenu::NameChanged), 114 | Options(1,SUI_STR("Options"),SUI_STR("Choose one of these"),SUI_STR("A"),SUI_STR("B"),SUI_STR("or C"),NULL,NULL,NULL,MainMenu::OptionsChanged) 115 | {} 116 | } MyInputsContainerSt; 117 | 118 | extern MyInputsContainerSt MyInputs; 119 | 120 | 121 | 122 | 123 | 124 | /* ***** SetupSerialUI: where we'll be setting up menus and such **** */ 125 | bool SetupSerialUI(); 126 | 127 | 128 | #define DIE_HORRIBLY(msg) for(;;){ MySUI.println(msg); delay(1000); } 129 | 130 | 131 | #endif 132 | -------------------------------------------------------------------------------- /src/includes/python/ExternalModule.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Part of the SerialUI project. 4 | * Copyright (C) 2019 Pat Deegan, psychogenic.com 5 | * See LICENSE file for details, or 6 | * https://devicedruid.com/ 7 | * and https://inductive-kickback.com/ 8 | * 9 | */ 10 | 11 | #ifndef SUI_PYTHON_EXTERNAL_MODULE 12 | #define SUI_PYTHON_EXTERNAL_MODULE 13 | 14 | #include "../SerialUIPlatform.h" 15 | 16 | #ifdef SERIALUI_PYTHONMODULES_SUPPORT_ENABLE 17 | 18 | #include "../SerialUITypes.h" 19 | #include "../menuitem/items.h" 20 | #include "../tracked/tracked.h" 21 | #include "pyhelper.hpp" 22 | 23 | 24 | // class ::SerialUI::SerialUI; // forward decl 25 | 26 | #ifdef SERIALUI_AUTHENTICATOR_ENABLE 27 | #include "../auth/AuthValidator.h" 28 | #endif 29 | 30 | #define SUI_EXTMODULE_VERSION_MAJOR 1 31 | #define SUI_EXTMODULE_VERSION_MINOR 2 32 | #define SUI_EXTMODULE_VERSION_PATCH 0 33 | 34 | #define SUI_EXTMODULE_NAME_HANDLERCLASS "SerialUIHandler" 35 | #define SUI_EXTMODULE_NAME_HEARTBEAT_METHOD "heartbeat" 36 | #define SUI_EXTMODULE_NAME_LOADCOMPLETE_METHOD "loaded" 37 | #define SUI_EXTMODULE_NAME_USERENTERED_METHOD "userEnter" 38 | #define SUI_EXTMODULE_NAME_USEREXIT_METHOD "userExit" 39 | 40 | 41 | namespace SerialUI { 42 | namespace Python { 43 | 44 | 45 | typedef struct ExtModVersionStruct { 46 | uint8_t vmajor; 47 | uint8_t vminor; 48 | uint8_t vpatch; 49 | ExtModVersionStruct() : 50 | vmajor(SUI_EXTMODULE_VERSION_MAJOR), 51 | vminor(SUI_EXTMODULE_VERSION_MINOR), 52 | vpatch(SUI_EXTMODULE_VERSION_PATCH) 53 | { 54 | 55 | } 56 | } ExternalModuleVersion; 57 | 58 | class ExternalModule { 59 | public: 60 | 61 | static ExternalModuleVersion version() { 62 | return ExternalModuleVersion(); 63 | } 64 | 65 | // ExternalModule(SerialUI * driver, DynamicString name); 66 | ExternalModule(void * serialUIDriver, 67 | DynamicString name, 68 | DynamicString path=NULL); 69 | ~ExternalModule(); 70 | 71 | bool callHandlerMethod(DynamicString name); 72 | bool load(); 73 | 74 | 75 | bool trigger(Menu::Item::Command * cmd); 76 | bool trigger(Menu::Item::Request::Request * req); 77 | 78 | bool isValidTrigger(Menu::Item::Request::Request * req, unsigned long val); 79 | bool isValidTrigger(Menu::Item::Request::Request * req, long val); 80 | bool isValidTrigger(Menu::Item::Request::Request * req, float val); 81 | bool isValidTrigger(Menu::Item::Request::Request * req, bool val); 82 | bool isValidTrigger(Menu::Item::Request::Request * req, TopLevelString & val); 83 | /* 84 | template 85 | bool isValidTrigger(Menu::Item::Request::Request * req, VALTYPE val) { 86 | SERIALUI_DEBUG_OUT(F("ExternalModule::isValidTrigger() ")); 87 | if (!load()) { 88 | SERIALUI_DEBUG_OUTLN(F("could not load")); 89 | return true; // won't deny 90 | } 91 | SERIALUI_DEBUG_OUT(" for:"); 92 | SERIALUI_DEBUG_OUTLN(req->key()); 93 | return SUIPyObjectsStore.callValidatorOnInputs(req->id(), val); 94 | } 95 | */ 96 | 97 | bool triggerHeartbeat(); 98 | bool setHearbeatPeriod(unsigned long ms); 99 | 100 | 101 | void updated(Menu::Item::Request::Request * req); 102 | void updated(Tracked::State* st); 103 | 104 | void userEntered(); 105 | void userExit(); 106 | 107 | #ifdef SERIALUI_AUTHENTICATOR_ENABLE 108 | Auth::Validator * authValidator(); 109 | Auth::Storage * authStorage() ; 110 | private: 111 | Auth::Validator * auth_validator; 112 | Auth::Storage * auth_storage; 113 | #endif 114 | 115 | 116 | private: 117 | DynamicString module_name; 118 | DynamicString module_path; 119 | DynamicString post_load_call; 120 | bool is_loaded; 121 | bool load_attempted; 122 | CPyObject pModule; 123 | CPyObject pHandler; 124 | CPyObject pHeartbeat; 125 | CPyInstance * hInstance; 126 | void * driver; 127 | uint8_t reserved[64]; // space to use up for additions, to maintain binary compat of drivers 128 | }; 129 | 130 | 131 | 132 | } 133 | } 134 | 135 | #endif /* SERIALUI_PYTHONMODULES_SUPPORT_ENABLE */ 136 | 137 | #endif /* SUI_PYTHON_EXTERNAL_MODULE */ 138 | -------------------------------------------------------------------------------- /src/includes/SerialUITypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SerialUITypes.h 3 | * 4 | * Created on: May 25, 2018 5 | * Author: Pat Deegan 6 | * 7 | * SerialUITypes is part of the SerialUI project. 8 | * Copyright (C) 2018-2019 Pat Deegan, psychogenic.com 9 | */ 10 | 11 | #ifndef SERIALUIV3_SRC_INCLUDES_SERIALUITYPES_H_ 12 | #define SERIALUIV3_SRC_INCLUDES_SERIALUITYPES_H_ 13 | 14 | #include "SerialUIExtIncludes.h" 15 | #include "SerialUIPlatform.h" 16 | 17 | #define SERIAL_UI_REQUEST_NOINPUT 0xf0 18 | 19 | namespace SerialUI { 20 | 21 | typedef ::String TopLevelString; 22 | typedef uint32_t TimeValue; 23 | typedef uint8_t StaticStringLength; 24 | 25 | 26 | namespace Weekday { 27 | 28 | typedef enum { 29 | ANY = 0, 30 | Sunday = 1, 31 | Monday = 2, 32 | Tuesday = 3, 33 | Wednesday = 4, 34 | Thursday = 5, 35 | Friday = 6, 36 | Saturday = 7, 37 | } day; 38 | 39 | } 40 | 41 | 42 | namespace Mode { 43 | typedef enum { 44 | User = 0, Program 45 | } Selection; 46 | 47 | } 48 | namespace Tracked { 49 | 50 | typedef uint8_t ID; 51 | 52 | namespace Type { 53 | typedef enum TrackedTypeEnum { 54 | INVALID = 0x00, 55 | Char = 0x01, 56 | Bool = 0x02, 57 | Toggle = 0x03, 58 | Int = 0x04, 59 | UInt = 0x05, 60 | BoundedLongInt = 0x06, 61 | OptionsList = 0x07, 62 | Float = 0x08, 63 | String = 0x09, 64 | DateTime = 0x0A, 65 | Time = 0x0B, 66 | Event = 0x0C, 67 | 68 | WeeklySchedule = 0x0D, // TODO:FIXME 69 | 70 | 71 | OUTOFBOUNDS = 0x0E 72 | } Value; 73 | 74 | } 75 | 76 | namespace View { 77 | typedef enum TrackedViewTypeEnum { 78 | CurrentValue = 0x01, 79 | HistoryLog = 0x02, 80 | ChartBar = 0x03, 81 | ChartLineBasic = 0x04, 82 | ChartLineBoundaries = 0x05, 83 | ChartPie = 0x06 84 | } Type; 85 | } 86 | } /* namespace Tracked */ 87 | 88 | namespace Request { 89 | namespace Type { 90 | typedef enum { 91 | INVALID = 0x0, BuiltIn = 0x01, MenuItem = 0x02, 92 | } Value; 93 | } 94 | 95 | namespace BuiltIn { 96 | typedef enum { 97 | INVALID = 0x0, 98 | UpLevel = 0x01, 99 | ModeUser = 0x02, 100 | ModeProgram = 0x03, 101 | ListMenu = 0x04, 102 | Help = 0x05, 103 | RefreshTracked = 0x06, 104 | Exit = 0x07 105 | 106 | } Selection; 107 | 108 | } /* namespace BuiltIn */ 109 | } /* namespace Request */ 110 | 111 | namespace Menu { 112 | namespace Item { 113 | typedef uint8_t ID; 114 | 115 | typedef void (*CommandCallback)(void); 116 | 117 | namespace Type { 118 | 119 | typedef enum { 120 | INVALID = 0x00, 121 | 122 | Menu = 0x01, 123 | 124 | Command = 0x02, 125 | 126 | Input = 0x03, 127 | 128 | State = 0x04, 129 | 130 | StaticText = 0x05, 131 | 132 | DynamicText = 0x06, 133 | 134 | Group = 0x07, 135 | 136 | List = 0x08, 137 | 138 | TrackedView = 0x09, 139 | 140 | OUTOFBOUNDS = 0x0A // MUST be largest 141 | 142 | } Value; 143 | 144 | }/* namespace Type */ 145 | 146 | namespace Request { 147 | namespace Type { 148 | 149 | typedef enum { 150 | INVALID = 0x00, 151 | Character = 0x01, 152 | Boolean = 0x02, 153 | Toggle = 0x03, 154 | LongInt = 0x04, 155 | UnsignedLongInt = 0x05, 156 | BoundedLongInt = 0x06, 157 | OptionsList = 0x07, 158 | Float = 0x08, 159 | String = 0x09, 160 | DateTime = 0x0A, 161 | Time = 0x0B, 162 | Event = 0x0C, 163 | 164 | WeeklySchedule = 0x0D, // TODO 165 | 166 | Passphrase = 0x0E, 167 | 168 | Color = 0x0F, 169 | 170 | OUTOFBOUNDS = 0x10 171 | 172 | } Value; 173 | } 174 | } 175 | 176 | } /* namespace Item */ 177 | } /* namespace Menu */ 178 | 179 | namespace Auth { 180 | namespace Transmission { 181 | namespace Type { 182 | 183 | typedef enum { 184 | Plain = 0, 185 | MD5 = 1, 186 | SHA256 = 2, 187 | 188 | Custom = 0xff 189 | } Value; 190 | } /* namespace Type */ 191 | } /* namespace Transmission */ 192 | 193 | namespace Request { 194 | namespace Type { 195 | 196 | typedef enum { 197 | Authenticate = 1, 198 | Setup = 2, 199 | } Value ; 200 | 201 | } /* namespace Type */ 202 | } /* namespace Request */ 203 | } /* namespace Auth */ 204 | 205 | 206 | } /* namespace SerialUI */ 207 | 208 | #endif /* SERIALUIV3_SRC_INCLUDES_SERIALUITYPES_H_ */ 209 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SerialUI: Serial User Interface. 2 | Copyright (C) 2013-2019 Pat Deegan. All rights reserved. 3 | 4 | https://devicedruid.com 5 | https://inductive-kickback.com/projects/SerialUI 6 | 7 | SerialUI is released under the LGPL -- see 8 | LICENSE.txt for details. 9 | 10 | ********************* SerialUI Overview ********************* 11 | 12 | SerialUI is useful when you want to provide a user interface 13 | through the serial channel (menus, sub-menus and command 14 | execution). It provides built-in support for navigation 15 | through the menu hierarchy and online help. 16 | 17 | With SerialUI, you can create a hierarchy of menus and 18 | submenus of arbitrary depth (limited only by ROM/RAM space). 19 | 20 | Each menu contains a list of menu items. There are two 21 | types of SerialUI menu items: 22 | 23 | Sub menus: lead you to another level of menu items 24 | 25 | Commands: actually perform some type of action. 26 | 27 | Exactly _what_ happens when a user issues a command is 28 | determined by the callback implementations. 29 | 30 | A few commands are built-in and don't need to be defined: 31 | 32 | - '?': Help, which displays all the available menu keys and 33 | help messages, where defined. 34 | 35 | - '..': Up, which moves up to a parent menu from a sub-menu 36 | 37 | - 'quit': Exit the SerialUI interface (available in top level 38 | menu). 39 | 40 | Using SerialUI, you can create any serial user interface. 41 | Example menu hierarchy: 42 | 43 | + information 44 | | 45 | | 46 | + enable -----+ on 47 | | | 48 | | + off 49 | | 50 | | 51 | + settings ---------+ red 52 | | 53 | + green 54 | | 55 | + blue 56 | | 57 | + deviceid 58 | | 59 | + show 60 | 61 | 62 | So, here we'd have a three-option top level menu (information, 63 | enable, settings) with two of those options leading to 64 | sub-menus. 65 | 66 | Every "leaf" (option that doesn't lead to a sub-menu) is a 67 | command that uses a callback specified when setting up the 68 | menu item. 69 | 70 | 71 | ************************** TRANSCIPT ************************** 72 | 73 | Here's a sample of the interaction through the serial 74 | connection (created using the code in examples/SuperBlinker): 75 | 76 | +++ Welcome to the SuperBlinker +++ 77 | Enter '?' to list available options. 78 | > ? 79 | *** Help for: SuperBlinker Main Menu 80 | 81 | * information Retrieve data and current settings 82 | + enable Enable/disable device 83 | + settings Perform setup and config 84 | 85 | * quit Exit SerialUI 86 | * ? List available menu items 87 | > settings 88 | SuperBlinker Settings 89 | SuperBlinker Settings> ? 90 | *** Help for: SuperBlinker Settings 91 | 92 | * red Set color [0-255] 93 | * green 94 | * blue 95 | * deviceid Set dev ID [string] 96 | * show 97 | 98 | * .. Move up to parent menu 99 | * ? List available menu items 100 | SuperBlinker Settings> red 101 | ..# 10 102 | OK 103 | SuperBlinker Settings> green 104 | ..# 20 105 | OK 106 | SuperBlinker Settings> blue 107 | ..# 42 108 | OK 109 | SuperBlinker Settings> deviceid 110 | ... Yay Device! 111 | OK 112 | SuperBlinker Settings> show 113 | (Called 'show_info' from menu: SuperBlinker Settings) 114 | ID: Yay Device! 115 | Color--> R:10 G:20 B:42 116 | Device is OFF 117 | SuperBlinker Settings> .. 118 | SuperBlinker Main Menu 119 | > quit 120 | 121 | 122 | See examples/SuperBlinker for a full demo/tutorial. 123 | 124 | See INSTALL.txt for installation instructions. 125 | 126 | Please let me know if you use SerialUI in your projects, and 127 | provide a URL if you'd like me to link to it from the SerialUI 128 | home. 129 | 130 | Enjoy! 131 | Pat Deegan, psychogenic.com 132 | 133 | --------------------------------------------------------------------------------