Skip to content

Commit

Permalink
Merge remote-tracking branch 'ewowi/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
ewoudwijma committed Apr 16, 2024
2 parents 3f20332 + c8a56d1 commit baa7265
Show file tree
Hide file tree
Showing 13 changed files with 96 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: 'Upload Artifact'
uses: actions/upload-artifact@v3
with:
name: StarMod-esp32-${{env.git_branch}}-${{env.git_hash}}.bin
name: StarMod-esp32dev-${{env.git_branch}}-${{env.git_hash}}.bin
path: .pio/build/esp32dev/firmware.bin
retention-days: 30

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ See [StarDocs](https://ewowi.github.io/StarDocs/)
Forks:

* [MoonModules/StarModLeds](https://github.com/MoonModules/StarModLeds)

5 changes: 5 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,17 @@ build_flags =
${STARMOD_USERMOD_E131.build_flags}
; ${STARMOD_USERMOD_HA.build_flags}
${STARMOD_USERMOD_WLEDAUDIO.build_flags}
-DAPP=StarLeds
-DVERSION=24041415
-DPIOENV=$PIOENV
lib_deps =
${starmod.lib_deps}
${STARMOD_APPMOD_LEDS.lib_deps}
${STARMOD_USERMOD_E131.lib_deps}
; ${STARMOD_USERMOD_HA.lib_deps}
${STARMOD_USERMOD_WLEDAUDIO.lib_deps}
extra_scripts =
post:tools/post_build.py


[env:esp32dev]
Expand Down
10 changes: 8 additions & 2 deletions src/Sys/SysModSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void SysModSystem::setup() {
parentVar = ui->initSysMod(parentVar, name, 2000);
parentVar["s"] = true; //setup

ui->initText(parentVar, "instanceName", "StarMod", 32, false, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
ui->initText(parentVar, "instanceName", _INIT(TOSTRING(APP)), 32, false, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
case f_UIFun:
ui->setLabel(var, "Name");
ui->setComment(var, "Instance name");
Expand Down Expand Up @@ -172,7 +172,13 @@ void SysModSystem::setup() {

// USER_PRINTF("version %s %s %s %d:%d:%d\n", version, __DATE__, __TIME__, hour, minute, second);

ui->initNumber(parentVar, "version", VERSION, UINT16_MAX, UINT16_MAX, true);
strcat(build, _INIT(TOSTRING(APP)));
strcat(build, "_");
strcat(build, _INIT(TOSTRING(VERSION)));
strcat(build, "_");
strcat(build, _INIT(TOSTRING(PIOENV)));

ui->initText(parentVar, "build", build, 32, true);
// ui->initText(parentVar, "date", __DATE__, 16, true);
// ui->initText(parentVar, "time", __TIME__, 16, true);

Expand Down
2 changes: 1 addition & 1 deletion src/Sys/SysModSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class SysModSystem:public SysModule {

public:
// char version[16] = "";
char build[64] = "";
char chipInfo[64] = "";

SysModSystem();
Expand Down
4 changes: 2 additions & 2 deletions src/Sys/SysModWeb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -671,9 +671,9 @@ void SysModWeb::serveJson(WebRequest *request) {
root["info"]["name"] = mdl->getValue("instanceName");
root["info"]["arch"] = "esp32"; //platformName

root["info"]["rel"] = "StarMod";
root["info"]["rel"] = _INIT(TOSTRING(APP));
root["info"]["ver"] = "0.0.1";
root["info"]["vid"] = mdl->getValue("version").as<unsigned32>(); //WLED-native needs int otherwise status offline!!!
root["info"]["vid"] = VERSION; //WLED-native needs int otherwise status offline!!!
root["info"]["leds"]["count"] = 999;
root["info"]["leds"]["countP"] = 998;
root["info"]["leds"]["fps"] = mdl->getValue("fps"); //tbd: should be realFps but is ro var
Expand Down
5 changes: 4 additions & 1 deletion src/SysModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@

#pragma once

#define VERSION 2024041320 //update for each build. Time in GMT !!!
//make a string from pio variables (_INIT and STRINGIFY needed to make TOSTRING work)
#define _INIT(x) x
#define STRINGIFY(X) #X
#define TOSTRING(X) STRINGIFY(X)

//conventional (works)
// #define unsigned8 uint8_t
Expand Down
6 changes: 3 additions & 3 deletions src/User/UserModHA.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class UserModHA:public SysModule {
void connectedChanged() {
if (mdls->isConnected) {
// set device's details (optional)
device.setName("StarMod");
device.setSoftwareVersion("0.0.1");
device.setName(_INIT(TOSTRING(APP)));
device.setSoftwareVersion(_INIT(TOSTRING(VERSION)));
}

// configure light (optional)
Expand Down Expand Up @@ -76,7 +76,7 @@ class UserModHA:public SysModule {
WiFiClient client;
HADevice device;
HAMqtt* mqtt = new HAMqtt(client, device);
HALight* light = new HALight("starmod", HALight::BrightnessFeature | HALight::RGBFeature);
HALight* light = new HALight(_INIT(TOSTRING(APP)), HALight::BrightnessFeature | HALight::RGBFeature);
};

extern UserModHA *hamod;
2 changes: 1 addition & 1 deletion src/User/UserModInstances.h
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ class UserModInstances:public SysModule {
starModMessage.header.ip2 = localIP[2];
starModMessage.header.ip3 = localIP[3];
const char * instanceName = mdl->getValue("instanceName");
strncpy(starModMessage.header.name, instanceName?instanceName:"StarMod", sizeof(starModMessage.header.name)-1);
strncpy(starModMessage.header.name, instanceName?instanceName:_INIT(TOSTRING(APP)), sizeof(starModMessage.header.name)-1);
starModMessage.header.type = 32; //esp32 tbd: CONFIG_IDF_TARGET_ESP32S3 etc
starModMessage.header.insId = localIP[3]; //WLED: used in map of instances as index!
starModMessage.header.version = VERSION;
Expand Down
2 changes: 1 addition & 1 deletion src/User/UserModMDNS.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class UserModMDNS:public SysModule {

//reset cmDNS
const char * instanceName = mdl->getValue("instanceName");
if (strcmp(instanceName, "StarMod") == 0 )
if (strcmp(instanceName, _INIT(TOSTRING(APP))) == 0 )
sprintf(cmDNS, "star-%*s", 6, escapedMac.c_str() + 6);
else
strcpy(cmDNS, instanceName);
Expand Down
8 changes: 0 additions & 8 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@
@license For non GPL-v3 usage, commercial licenses must be purchased. Contact [email protected]
*/

// remove latest commit
// git reset --hard HEAD^
// git push origin -f

#warning ******************************************************************************************************************************
#warning ********** STARMOD IS LICENSED UNDER GPL-V3. BY INSTALLING STARMOD YOU IMPLICITLY ACCEPT THE TERMS AND CONDITIONS ********
#warning ******************************************************************************************************************************

#include "SysModule.h"
#include "SysModules.h"
#include "Sys/SysModPrint.h"
Expand Down
5 changes: 5 additions & 0 deletions tools/misc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ search range-based for loop
===========================
^(?=.*\bfor\b)(?=.*\b:\b).*$

remove latest commit
====================
git reset --hard HEAD^
git push origin -f


Make video from png and mov
===========================
Expand Down
64 changes: 64 additions & 0 deletions tools/post_build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# @title StarMod
# @file post_build.py
# @date 20240411
# @repo https://github.com/ewowi/StarMod, submit changes to this file as PRs to ewowi/StarMod
# @Authors https://github.com/ewowi/StarMod/commits/main
# @Copyright © 2024 Github StarMod Commit Authors
# @license GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
# @license For non GPL-v3 usage, commercial licenses must be purchased. Contact [email protected]

Import('env')
import os
import shutil
import gzip

print("")
print("***************************************************************************************************************************")
print("********** STARMOD IS LICENSED UNDER GPL-V3. BY INSTALLING STARMOD YOU IMPLICITLY ACCEPT THE TERMS AND CONDITIONS ********")
print("***************************************************************************************************************************")
print("")

isGitHub = "runner" in os.path.expanduser("~") #do not copy in github PlatformIO CI (/home/runner/ is output dir in github)

if isGitHub:
OUTPUT_DIR = "build_output{}".format(os.path.sep)
else:
OUTPUT_DIR = "{}{}Downloads{}".format(os.path.expanduser("~"), os.path.sep, os.path.sep)


def _get_cpp_define_value(env, define):
define_list = [item[-1] for item in env["CPPDEFINES"] if item[0] == define]
if define_list:
return define_list[0]
return None

def _create_dirs(dirs=["firmware", "map"]):
# check if output directories exist and create if necessary
if not os.path.isdir(OUTPUT_DIR):
os.mkdir(OUTPUT_DIR)
for d in dirs:
if not os.path.isdir("{}{}".format(OUTPUT_DIR, d)):
os.mkdir("{}{}".format(OUTPUT_DIR, d))

def bin_rename_copy(source, target, env):
app = _get_cpp_define_value(env, "APP")
version = _get_cpp_define_value(env, "VERSION")
pioenv = env["PIOENV"]

if isGitHub:
_create_dirs(["release"])
# create string with location and file names based on pioenv
bin_file = "{}release{}{}_{}_{}.bin".format(OUTPUT_DIR, os.path.sep, app, version, pioenv)
else:
bin_file = "{}{}_{}_{}.bin".format(OUTPUT_DIR, app, version, pioenv)

# check if new target files exist and remove if necessary
for f in [bin_file]: #map_file,
if os.path.isfile(f):
os.remove(f)

# copy firmware.bin to bin_file
shutil.copy(str(target[0]), bin_file)
print(" created " + bin_file)

env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", [bin_rename_copy])

0 comments on commit baa7265

Please sign in to comment.