feat: initial commit

This commit is contained in:
s3lph 2023-11-20 00:38:15 +01:00
commit 06a5abc2b6
Signed by: s3lph
GPG key ID: 0AA29A52FB33CFB5
9 changed files with 278 additions and 0 deletions

88
case/clock.scad Normal file
View file

@ -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();

BIN
case/clock.stl Normal file

Binary file not shown.

View file

@ -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

1
esp/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.pio

39
esp/include/README Normal file
View file

@ -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

46
esp/lib/README Normal file
View file

@ -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 <Foo.h>
#include <Bar.h>
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

20
esp/platformio.ini Normal file
View file

@ -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

51
esp/src/main.cpp Normal file
View file

@ -0,0 +1,51 @@
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <NTP.h>
#include <Adafruit_NeoPixel.h>
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();
}

11
esp/test/README Normal file
View file

@ -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