From 090780e658f98b24f03655ae2f19e33c9dba511b Mon Sep 17 00:00:00 2001 From: Noah Axon Date: Sun, 24 Sep 2023 20:55:42 -0500 Subject: [PATCH] Cleanup * Moved all TV-B-Gone definitions and helper functions to tvbg.h. * Moved all AppleJuice definitions and helper functions to applejuice.h * Cleaned up the credits screen, added QR code, required changing credits background to white. * Tidy up formatting and comments. * Main ino file contains only process control and core functions. --- applejuice.h | 37 +++++++ m5stick-nemo.ino | 269 ++++++++++------------------------------------- tvbg.h | 127 ++++++++++++++++++++++ 3 files changed, 220 insertions(+), 213 deletions(-) create mode 100644 applejuice.h diff --git a/applejuice.h b/applejuice.h new file mode 100644 index 0000000..38ade3b --- /dev/null +++ b/applejuice.h @@ -0,0 +1,37 @@ +#include +// globals for passing bluetooth info between routines +// AppleJuice Payload Data +uint8_t Airpods[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x02, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +uint8_t AirpodsPro[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0e, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +uint8_t AirpodsMax[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0a, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +uint8_t AirpodsGen2[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0f, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +uint8_t AirpodsGen3[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x13, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +uint8_t AirpodsProGen2[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x14, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +uint8_t PowerBeats[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x03, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +uint8_t PowerBeatsPro[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0b, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +uint8_t BeatsSoloPro[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0c, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +uint8_t BeatsStudioBuds[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x11, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +uint8_t BeatsFlex[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x10, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +uint8_t BeatsX[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x05, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +uint8_t BeatsSolo3[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x06, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +uint8_t BeatsStudio3[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x09, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +uint8_t BeatsStudioPro[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x17, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +uint8_t BeatsFitPro[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x12, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +uint8_t BeatsStudioBudsPlus[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x16, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +uint8_t AppleTVSetup[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x01, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; +uint8_t AppleTVPair[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x06, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; +uint8_t AppleTVNewUser[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x20, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; +uint8_t AppleTVAppleIDSetup[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x2b, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; +uint8_t AppleTVWirelessAudioSync[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0xc0, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; +uint8_t AppleTVHomekitSetup[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x0d, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; +uint8_t AppleTVKeyboard[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x13, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; +uint8_t AppleTVConnectingToNetwork[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x27, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; +uint8_t HomepodSetup[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x0b, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; +uint8_t SetupNewPhone[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x09, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; +uint8_t TransferNumber[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x02, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; +uint8_t TVColorBalance[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x1e, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; +uint8_t* data; +int deviceType = 0; + +BLEAdvertisementData oAdvertisementData = BLEAdvertisementData(); +BLEAdvertising *pAdvertising; diff --git a/m5stick-nemo.ino b/m5stick-nemo.ino index e649f8d..551df46 100644 --- a/m5stick-nemo.ino +++ b/m5stick-nemo.ino @@ -4,6 +4,7 @@ #include #include #include +#include "applejuice.h" #include "WORLD_IR_CODES.h" #include #include @@ -12,53 +13,15 @@ int advtime = 0; String formattedDate; String dayStamp; String timeStamp; - -// globals for passing bluetooth info between routines -// AppleJuice Payload Data -uint8_t Airpods[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x02, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -uint8_t AirpodsPro[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0e, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -uint8_t AirpodsMax[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0a, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -uint8_t AirpodsGen2[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0f, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -uint8_t AirpodsGen3[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x13, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -uint8_t AirpodsProGen2[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x14, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -uint8_t PowerBeats[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x03, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -uint8_t PowerBeatsPro[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0b, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -uint8_t BeatsSoloPro[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0c, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -uint8_t BeatsStudioBuds[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x11, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -uint8_t BeatsFlex[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x10, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -uint8_t BeatsX[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x05, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -uint8_t BeatsSolo3[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x06, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -uint8_t BeatsStudio3[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x09, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -uint8_t BeatsStudioPro[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x17, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -uint8_t BeatsFitPro[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x12, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -uint8_t BeatsStudioBudsPlus[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x16, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -uint8_t AppleTVSetup[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x01, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; -uint8_t AppleTVPair[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x06, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; -uint8_t AppleTVNewUser[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x20, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; -uint8_t AppleTVAppleIDSetup[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x2b, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; -uint8_t AppleTVWirelessAudioSync[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0xc0, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; -uint8_t AppleTVHomekitSetup[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x0d, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; -uint8_t AppleTVKeyboard[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x13, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; -uint8_t AppleTVConnectingToNetwork[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x27, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; -uint8_t HomepodSetup[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x0b, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; -uint8_t SetupNewPhone[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x09, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; -uint8_t TransferNumber[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x02, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; -uint8_t TVColorBalance[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x1e, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; -uint8_t* data; -int deviceType = 0; - -BLEAdvertisementData oAdvertisementData = BLEAdvertisementData(); -BLEAdvertising *pAdvertising; - +int cursor = 0; +int rotation = 1; +bool rstOverride = false; #define EEPROM_SIZE 1 struct MENU { char name[19]; int command; }; -int cursor = 0; -int rotation = 1; -bool rstOverride = false; /// SWITCHER /// // Proc codes @@ -72,6 +35,7 @@ bool rstOverride = false; // 7 - screen rotation // 8 - AppleJuice Menu // 9 - AppleJuice Advertisement +// 10 - Credits bool isSwitching = true; int current_proc = 0; // Start in Clock Mode @@ -280,6 +244,7 @@ void rmenu_loop() { } } +/// BATTERY INFO /// void battery_drawmenu(int battery, int b, int c) { M5.Lcd.setTextSize(2); M5.Lcd.fillScreen(BLACK); @@ -318,41 +283,6 @@ void battery_loop() { } /// TV-B-GONE /// -void xmitCodeElement(uint16_t ontime, uint16_t offtime, uint8_t PWM_code ); -void quickflashLEDx( uint8_t x ); -void delay_ten_us(uint16_t us); -void quickflashLED( void ); -uint8_t read_bits(uint8_t count); -uint16_t rawData[300]; -#define MAX_WAIT_TIME 65535 //tens of us (ie: 655.350ms) -IRsend irsend(IRLED); // Set the GPIO to be used to sending the message. -extern const IrCode* const NApowerCodes[]; -extern const IrCode* const EUpowerCodes[]; -extern uint8_t num_NAcodes, num_EUcodes; -uint8_t bitsleft_r = 0; -uint8_t bits_r = 0; -uint8_t code_ptr; -volatile const IrCode * powerCode; -uint8_t read_bits(uint8_t count) -{ - uint8_t i; - uint8_t tmp = 0; - for (i = 0; i < count; i++) { - if (bitsleft_r == 0) { - bits_r = powerCode->codes[code_ptr++]; - bitsleft_r = 8; - } - bitsleft_r--; - tmp |= (((bits_r >> (bitsleft_r)) & 1) << (count - 1 - i)); - } - return tmp; -} -#define BUTTON_PRESSED LOW -#define BUTTON_RELEASED HIGH -uint16_t ontime, offtime; -uint8_t i, num_codes; -uint8_t region; - void tvbgone_setup() { M5.Lcd.fillScreen(BLACK); M5.Lcd.setTextSize(4); @@ -374,72 +304,6 @@ void tvbgone_setup() { delay(1000); // Give time after loading } -void sendAllCodes() -{ - bool endingEarly = false; //will be set to true if the user presses the button during code-sending - if (digitalRead(REGIONSWITCH)) { - region = NA; - num_codes = num_NAcodes; - } - else { - region = EU; - num_codes = num_EUcodes; - } - for (i = 0 ; i < num_codes; i++) - { - if (region == NA) { - powerCode = NApowerCodes[i]; - } - else { - powerCode = EUpowerCodes[i]; - } - const uint8_t freq = powerCode->timer_val; - const uint8_t numpairs = powerCode->numpairs; - M5.Lcd.fillScreen(BLACK); - M5.Lcd.setTextSize(4); - M5.Lcd.setCursor(5, 1); - M5.Lcd.println("TV-B-Gone"); - M5.Lcd.setTextSize(2); - const uint8_t bitcompression = powerCode->bitcompression; - code_ptr = 0; - for (uint8_t k = 0; k < numpairs; k++) { - uint16_t ti; - ti = (read_bits(bitcompression)) * 2; - offtime = powerCode->times[ti]; // read word 1 - ontime - ontime = powerCode->times[ti + 1]; // read word 2 - offtime - M5.Lcd.setTextSize(1); - M5.Lcd.printf("rti = %d Pair = %d, %d\n", ti >> 1, ontime, offtime); - rawData[k * 2] = offtime * 10; - rawData[(k * 2) + 1] = ontime * 10; - yield(); - } - irsend.sendRaw(rawData, (numpairs * 2) , freq); - // Hack: Set IRLED high to turn it off after each burst. Otherwise it stays on (active low) - digitalWrite(IRLED, HIGH); - yield(); - bitsleft_r = 0; - delay_ten_us(20500); - if (digitalRead(TRIGGER) == BUTTON_PRESSED) - { - while (digitalRead(TRIGGER) == BUTTON_PRESSED) { - yield(); - } - endingEarly = true; - delay_ten_us(50000); //500ms delay - quickflashLEDx(4); - delay_ten_us(MAX_WAIT_TIME); // wait 655.350ms - delay_ten_us(MAX_WAIT_TIME); // wait 655.350ms - break; //exit the POWER code "for" loop - } - } - if (endingEarly == false) - { - delay_ten_us(MAX_WAIT_TIME); // wait 655.350ms - delay_ten_us(MAX_WAIT_TIME); // wait 655.350ms - quickflashLEDx(8); - } -} - void tvbgone_loop() { if (digitalRead(TRIGGER) == BUTTON_PRESSED) @@ -454,32 +318,6 @@ void tvbgone_loop() yield(); } -void delay_ten_us(uint16_t us) { - uint8_t timer; - while (us != 0) { - for (timer = 0; timer <= DELAY_CNT; timer++) { - NOP; - NOP; - } - NOP; - us--; - } -} - -void quickflashLED( void ) { - digitalWrite(LED, LOW); - delay_ten_us(3000); // 30 ms ON-time delay - digitalWrite(LED, HIGH); -} - -void quickflashLEDx( uint8_t x ) { - quickflashLED(); - while (--x) { - delay_ten_us(25000); // 250 ms OFF-time delay between flashes - quickflashLED(); - } -} - /// CLOCK /// void clock_setup() { M5.Lcd.setRotation(rotation); @@ -515,6 +353,7 @@ void timeset_drawmenu(int nums) { } } +/// TIME SETTING /// void timeset_setup() { rstOverride = true; M5.Lcd.fillScreen(BLACK); @@ -565,40 +404,7 @@ void timeset_loop() { current_proc = 0; } -/// ENTRY /// -void setup() { - M5.begin(); - M5.Axp.ScreenBreath(11); // Brightness - M5.Lcd.setRotation(rotation); - M5.Lcd.setTextColor(GREEN, BLACK); - EEPROM.begin(EEPROM_SIZE); - rotation = EEPROM.read(0); - - // Boot Screen - digitalWrite(M5_LED, HIGH); //LEDOFF - M5.Lcd.fillScreen(BLACK); - M5.Lcd.setTextSize(4); - M5.Lcd.setCursor(40, 15); - M5.Lcd.setRotation(rotation); - M5.Lcd.print("M5-NEMO\n"); - // Pin setup - pinMode(M5_LED, OUTPUT); - pinMode(M5_BUTTON_HOME, INPUT); - pinMode(M5_BUTTON_RST, INPUT); - - // Random seed - randomSeed(analogRead(0)); - - // Create the BLE Server - BLEDevice::init(""); - BLEServer *pServer = BLEDevice::createServer(); - pAdvertising = pServer->getAdvertising(); - BLEAdvertisementData oAdvertisementData = BLEAdvertisementData(); - - // Finish with time to show logo - delay(3000); -} - +/// AppleJuice /// MENU ajmenu[] = { { "AirPods", 1}, { "AirPods Pro", 2}, @@ -814,21 +620,58 @@ void aj_adv(){ } } +/// CREDITS /// void credits_setup(){ - M5.Lcd.fillScreen(BLACK); - M5.Lcd.setTextSize(3); - M5.Lcd.setCursor(5, 10); M5.Lcd.setRotation(rotation); - M5.Lcd.print("M5-NEMO\n"); + M5.Lcd.fillScreen(WHITE); + M5.Lcd.qrcode("https://github.com/n0xa/m5stick-nemo", 145, 40, 100, 5); + M5.Lcd.setTextColor(BLACK, WHITE); + M5.Lcd.setTextSize(3); + M5.Lcd.setCursor(0, 25); + M5.Lcd.print(" M5-NEMO\n"); M5.Lcd.setTextSize(2); - M5.Lcd.println("For M5StickC-Plus"); + M5.Lcd.println(" For M5Stack"); + M5.Lcd.println(" StickC-Plus"); M5.Lcd.println("By Noah Axon"); - M5.Lcd.println("| Instagram: @4x0nn"); - M5.Lcd.println("| GitHub: n0xa"); + M5.Lcd.setCursor(155, 5); + M5.Lcd.println("GitHub"); + M5.Lcd.setCursor(155, 25); + M5.Lcd.println("Source:"); + M5.Lcd.setTextColor(GREEN, BLACK); } -void credits(){ - delay(50); +/// ENTRY /// +void setup() { + M5.begin(); + M5.Axp.ScreenBreath(11); // Brightness + M5.Lcd.setRotation(rotation); + M5.Lcd.setTextColor(GREEN, BLACK); + EEPROM.begin(EEPROM_SIZE); + rotation = EEPROM.read(0); + + // Boot Screen + digitalWrite(M5_LED, HIGH); //LEDOFF + M5.Lcd.fillScreen(BLACK); + M5.Lcd.setTextSize(4); + M5.Lcd.setCursor(40, 15); + M5.Lcd.setRotation(rotation); + M5.Lcd.print("M5-NEMO\n"); + // Pin setup + pinMode(M5_LED, OUTPUT); + pinMode(M5_BUTTON_HOME, INPUT); + pinMode(M5_BUTTON_RST, INPUT); + + // Random seed + randomSeed(analogRead(0)); + + // Create the BLE Server + BLEDevice::init(""); + BLEServer *pServer = BLEDevice::createServer(); + pAdvertising = pServer->getAdvertising(); + BLEAdvertisementData oAdvertisementData = BLEAdvertisementData(); + + // Finish with time to show logo + delay(3000); } void loop() { @@ -909,7 +752,7 @@ void loop() { aj_adv(); break; case 10: - credits(); - break; + // noop - just let the credits stay on screen + break; } } diff --git a/tvbg.h b/tvbg.h index a3896f8..81ead32 100644 --- a/tvbg.h +++ b/tvbg.h @@ -47,3 +47,130 @@ struct IrCode { uint16_t const *times; uint8_t const *codes; }; + +void xmitCodeElement(uint16_t ontime, uint16_t offtime, uint8_t PWM_code ); +void quickflashLEDx( uint8_t x ); +void delay_ten_us(uint16_t us); +void quickflashLED( void ); +uint8_t read_bits(uint8_t count); +uint16_t rawData[300]; +#define MAX_WAIT_TIME 65535 //tens of us (ie: 655.350ms) +IRsend irsend(IRLED); // Set the GPIO to be used to sending the message. +extern const IrCode* const NApowerCodes[]; +extern const IrCode* const EUpowerCodes[]; +extern uint8_t num_NAcodes, num_EUcodes; +uint8_t bitsleft_r = 0; +uint8_t bits_r = 0; +uint8_t code_ptr; +volatile const IrCode * powerCode; +uint8_t read_bits(uint8_t count) +{ + uint8_t i; + uint8_t tmp = 0; + for (i = 0; i < count; i++) { + if (bitsleft_r == 0) { + bits_r = powerCode->codes[code_ptr++]; + bitsleft_r = 8; + } + bitsleft_r--; + tmp |= (((bits_r >> (bitsleft_r)) & 1) << (count - 1 - i)); + } + return tmp; +} +#define BUTTON_PRESSED LOW +#define BUTTON_RELEASED HIGH +uint16_t ontime, offtime; +uint8_t i, num_codes; +uint8_t region; + +void sendAllCodes() +{ + bool endingEarly = false; //will be set to true if the user presses the button during code-sending + if (digitalRead(REGIONSWITCH)) { + region = NA; + num_codes = num_NAcodes; + } + else { + region = EU; + num_codes = num_EUcodes; + } + for (i = 0 ; i < num_codes; i++) + { + if (region == NA) { + powerCode = NApowerCodes[i]; + } + else { + powerCode = EUpowerCodes[i]; + } + const uint8_t freq = powerCode->timer_val; + const uint8_t numpairs = powerCode->numpairs; + M5.Lcd.fillScreen(BLACK); + M5.Lcd.setTextSize(4); + M5.Lcd.setCursor(5, 1); + M5.Lcd.println("TV-B-Gone"); + M5.Lcd.setTextSize(2); + const uint8_t bitcompression = powerCode->bitcompression; + code_ptr = 0; + for (uint8_t k = 0; k < numpairs; k++) { + uint16_t ti; + ti = (read_bits(bitcompression)) * 2; + offtime = powerCode->times[ti]; // read word 1 - ontime + ontime = powerCode->times[ti + 1]; // read word 2 - offtime + M5.Lcd.setTextSize(1); + M5.Lcd.printf("rti = %d Pair = %d, %d\n", ti >> 1, ontime, offtime); + rawData[k * 2] = offtime * 10; + rawData[(k * 2) + 1] = ontime * 10; + yield(); + } + irsend.sendRaw(rawData, (numpairs * 2) , freq); + // Hack: Set IRLED high to turn it off after each burst. Otherwise it stays on (active low) + digitalWrite(IRLED, HIGH); + yield(); + bitsleft_r = 0; + delay_ten_us(20500); + if (digitalRead(TRIGGER) == BUTTON_PRESSED) + { + while (digitalRead(TRIGGER) == BUTTON_PRESSED) { + yield(); + } + endingEarly = true; + delay_ten_us(50000); //500ms delay + quickflashLEDx(4); + delay_ten_us(MAX_WAIT_TIME); // wait 655.350ms + delay_ten_us(MAX_WAIT_TIME); // wait 655.350ms + break; //exit the POWER code "for" loop + } + } + if (endingEarly == false) + { + delay_ten_us(MAX_WAIT_TIME); // wait 655.350ms + delay_ten_us(MAX_WAIT_TIME); // wait 655.350ms + quickflashLEDx(8); + } +} + +void delay_ten_us(uint16_t us) { + uint8_t timer; + while (us != 0) { + for (timer = 0; timer <= DELAY_CNT; timer++) { + NOP; + NOP; + } + NOP; + us--; + } +} + +void quickflashLED( void ) { + digitalWrite(LED, LOW); + delay_ten_us(3000); // 30 ms ON-time delay + digitalWrite(LED, HIGH); +} + +void quickflashLEDx( uint8_t x ) { + quickflashLED(); + while (--x) { + delay_ten_us(25000); // 250 ms OFF-time delay between flashes + quickflashLED(); + } +}