commit 06a5abc2b61ad83b347b9fda69129d39132d40fe Author: s3lph Date: Mon Nov 20 00:38:15 2023 +0100 feat: initial commit diff --git a/case/clock.scad b/case/clock.scad new file mode 100644 index 0000000..8ff3f81 --- /dev/null +++ b/case/clock.scad @@ -0,0 +1,88 @@ +$fn=60; + +U=411; +R=U/(2*PI); +H=20; + +module frame() { + rotate([0,0,3]) { + difference() { + union() { + // fins + for (i=[0:59]) { + rotate([0,0,6*i]) { + translate([0,R+2,1]) { + cube([1,13,H]); + } + } + } + // base plate + cylinder(h=2, r=R+15); + // back plate + translate([0,0,H-2]) { + cylinder(h=2, r=R); + } + // outer back plate + translate([0,0,H-1]) { + difference() { + cylinder(h=2, r=R+15); + translate([0,0,-1]) { + cylinder(h=4, r=R+10); + } + } + } + // led mounting cylinder + translate([0,0,1]) { + cylinder(h=H, r=R); + } + } + // middle cutout + translate([0,0,-1]) { + cylinder(h=H+1, r=R-3); + } + // frontplate mounting hole + for (i=[0:30:359]) { + rotate([0,0,i-3]) { + translate([0,R+7,-1]) { + cylinder(h=4, r=2); + } + } + } + // cable feed hole + rotate([0,0,-3]) { + translate([0,-R-1.9,2]) { + rotate([0,0,25]) { + cube([20,2,H-2]); + } + } + } + rotate([0,0,-3]) { + // back plate mounting hole + translate([0,R-10,H-3]) { + hull() { + cylinder(h=4, r=2.5); + translate([0,-10,0]) { + cylinder(h=5, r=7.5); + } + } + } + // back plate button holes + translate([20,0,H-1]) { + cylinder(h=4, r=2.5); + } + translate([-20,0,H-1]) { + cylinder(h=4, r=2.5); + } + // cabling holes + translate([0,R+1, H-2]) { + rotate([90,0,0]) { + cylinder(h=5, r=2); + } + } + } + } + } +} + + +frame(); \ No newline at end of file diff --git a/case/clock.stl b/case/clock.stl new file mode 100644 index 0000000..26178b9 Binary files /dev/null and b/case/clock.stl differ diff --git a/esp/.forgejo/workflows/build.yml b/esp/.forgejo/workflows/build.yml new file mode 100644 index 0000000..6dbc95e --- /dev/null +++ b/esp/.forgejo/workflows/build.yml @@ -0,0 +1,22 @@ +--- + +on: push + +jobs: + + platformio: + runs-on: docker + steps: + - uses: https://code.forgejo.org/actions/checkout@v4 + - run: | + apt update; apt install python3-pip + pip3 install platformio + pio run + + openscad: + runs-on: docker + steps: + - uses: https://code.forgejo.org/actions/checkout@v4 + - run: | + apt update; apt install openscad + openscad -o pipeline.stl case/clock.scad diff --git a/esp/.gitignore b/esp/.gitignore new file mode 100644 index 0000000..03f4a3c --- /dev/null +++ b/esp/.gitignore @@ -0,0 +1 @@ +.pio diff --git a/esp/include/README b/esp/include/README new file mode 100644 index 0000000..194dcd4 --- /dev/null +++ b/esp/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/esp/lib/README b/esp/lib/README new file mode 100644 index 0000000..6debab1 --- /dev/null +++ b/esp/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +PlatformIO Library Dependency Finder will find automatically dependent +libraries scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/esp/platformio.ini b/esp/platformio.ini new file mode 100644 index 0000000..39bbc1a --- /dev/null +++ b/esp/platformio.ini @@ -0,0 +1,20 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:main] +platform = espressif8266 +board = nodemcu +framework = arduino +upload_protocol = esptool +lib_deps = + adafruit/Adafruit NeoPixel@^1.11.0 + sstaub/NTP@^1.6 +;board_build.mcu = esp8266 +;board_build.f_cpu = 80000000L \ No newline at end of file diff --git a/esp/src/main.cpp b/esp/src/main.cpp new file mode 100644 index 0000000..bb48e6f --- /dev/null +++ b/esp/src/main.cpp @@ -0,0 +1,51 @@ + +#include +#include +#include +#include + +Adafruit_NeoPixel pixels(60, 5, NEO_GRB + NEO_KHZ800); + + +const char *ssid = "kabelsalat-2ghz"; +const char *password = "club mate cola"; + +WiFiUDP wifiUdp; +NTP ntp(wifiUdp); + +void setup() { + Serial.begin(115200); + WiFi.begin(ssid, password); + while (WiFi.status() != WL_CONNECTED) { + Serial.println("Connecting ..."); + delay(500); + } + Serial.println("Connected"); + ntp.ruleDST("CEST", Last, Sun, Mar, 2, 120); // last sunday in march 2:00, timetone +120min (+1 GMT + 1h summertime offset) + ntp.ruleSTD("CET", Last, Sun, Oct, 3, 60); // last sunday in october 3:00, timezone +60min (+1 GMT) + ntp.begin(); + Serial.println("start NTP"); + pixels.begin(); +} + +uint8_t sixtyToPixel(int8_t sixty) { + return (60 - ((sixty+30) % 60)) % 60; +} + +void loop() { + delay(1000); + ntp.update(); + Serial.println(ntp.formattedTime("%T")); + uint8_t h = sixtyToPixel((ntp.hours() % 12) * 5 + (ntp.minutes() / 12)); + uint8_t hl = sixtyToPixel((ntp.hours() % 12) * 5 + (ntp.minutes() / 12) - 1); + uint8_t hr = sixtyToPixel((ntp.hours() % 12) * 5 + (ntp.minutes() / 12) + 1); + uint8_t m = sixtyToPixel(ntp.minutes()); + uint8_t s = sixtyToPixel(ntp.seconds()); + pixels.clear(); + pixels.setPixelColor(hl, pixels.getPixelColor(hl) | 0x00ff0000); + pixels.setPixelColor(h, pixels.getPixelColor(h) | 0x00ff0000); + pixels.setPixelColor(hr, pixels.getPixelColor(hr) | 0x00ff0000); + pixels.setPixelColor(m, pixels.getPixelColor(m) | 0x0000ff60); + pixels.setPixelColor(s, pixels.getPixelColor(s) | 0x000000ff); + pixels.show(); +} diff --git a/esp/test/README b/esp/test/README new file mode 100644 index 0000000..9b1e87b --- /dev/null +++ b/esp/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PlatformIO Test Runner and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PlatformIO Unit Testing: +- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html