Skip to content

Commit

Permalink
Backport improvements from webui branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyrkan committed Jul 24, 2023
1 parent c0929ad commit 6476019
Show file tree
Hide file tree
Showing 33 changed files with 859 additions and 3,486 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Install ClangFormat
run: sudo apt-get install -y clang-format
- name: Install PlatformIO Core
run: pip install --upgrade platformio
- name: ClangFormat check
run: find ./src ./include -regex '.*\.\(cpp\|hpp\|cu\|c\|h\)' -exec clang-format --dry-run -Werror -style=file -i {} \;
- name: Build PlatformIO Project
run: pio run
- name: "Update experimental tag"
Expand Down
30 changes: 30 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

# Node
node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

# PIO/VSCode
.pio
.vscode
.env
include/README
lib/README
test/README

# Others
.env
215 changes: 127 additions & 88 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,50 +21,54 @@
## Overview

What it **CAN** do:
* Monitor coolant flow and temperature (using a "YF-B4"-type sensor and a thermistor)
* Monitor lids opening (using two microswitches)
* Monitor 3 separate voltages (< 50V, they have to share the same ground as the control board)
* Monitor for fire (using an LM393 IR flame sensor module)
* Control a 6 channels relays board for:
* CO2 laser activation (the main switch on an vanilla K40, not the "fire" button)
* Air-assist activation
* Cooling activation
* Lights activation
* Positioning laser diodes activation
* Alarm activation
* Control a motorized bed (based on [this design](https://civade.com/post/2020/08/23/D%c3%a9coupe-laser-CO2-K40-:-R%c3%a9alisation-d-un-lit-motoris%c3%a9), but it should work with other ones as long as the stepper can be controled using a DRV8825 driver)
* Expose sensors/state data through an API

- Monitor coolant flow and temperature (using a "YF-B4"-type sensor and a thermistor)
- Monitor lids opening (using two microswitches)
- Monitor 3 separate voltages (< 50V, they have to share the same ground as the control board)
- Monitor for fire (using an LM393 IR flame sensor module)
- Control a 6 channels relays board for:
- CO2 laser activation (the main switch on an vanilla K40, not the "fire" button)
- Air-assist activation
- Cooling activation
- Lights activation
- Positioning laser diodes activation
- Alarm activation
- Control a motorized bed (based on [this design](https://civade.com/post/2020/08/23/D%c3%a9coupe-laser-CO2-K40-:-R%c3%a9alisation-d-un-lit-motoris%c3%a9), but it should work with other ones as long as the stepper can be controled using a DRV8825 driver)
- Expose sensors/state data through an API **(unstable)**

What it **CANNOT** do:
* Move the laser head
* Trigger the CO2 laser

- Move the laser head
- Trigger the CO2 laser

Also, don't expect an ultra smooth experience, the ESP32 being a bit underpowered for a screen of that size the user interface can be a bit laggy sometimes (eg. during screen transitions or scrolling). It should still be fully usable though.

## BOM

For the control panel:
* 1x NodeMCU-32 (38 pins)
* 1x ILI9488 3.95" LCD screen
* 1x DRV8825 stepper driver
* 2x 10kΩ 1/4W resistor
* 3x 27kΩ 1/4W resistors
* 3x 470kΩ 1/4W resistors
* 1x 0.1uF electrolytic capacitor
* 1x 100uF electrolytic capacitor
* 3x 0.1uF ceramic capacitors
* 2x 2P PCB terminal blocks (5mm pitch)
* some 2.54mm pin headers / XH connectors

- 1x NodeMCU-32 (38 pins)
- 1x ILI9488 3.95" LCD screen
- 1x DRV8825 stepper driver
- 2x 10kΩ 1/4W resistor
- 3x 27kΩ 1/4W resistors
- 3x 470kΩ 1/4W resistors
- 1x 0.1uF electrolytic capacitor
- 1x 100uF electrolytic capacitor
- 3x 0.1uF ceramic capacitors
- 2x 2P PCB terminal blocks (5mm pitch)
- some 2.54mm pin headers / XH connectors

Other things you may need:
* 1x motorized bed with a NEMA17 stepper and a limit switch
* 1x 6 channel relay board
* 1x air compressor for air assist
* 1x YF-B4 flow sensor with a thermistor (preferably one with a 50kΩ resistance at 25°C and B=3950K)
* 1x LM393 IR flame sensor module
* 2x micro switches
* 1x (or 2x depending on your needs) 5V laser diodes
* 1x 12V blinking light

- 1x motorized bed with a NEMA17 stepper and a limit switch
- 1x 6 channel relay board
- 1x air compressor for air assist
- 1x YF-B4 flow sensor with a thermistor (preferably one with a 50kΩ resistance at 25°C and B=3950K)
- 1x LM393 IR flame sensor module
- 2x micro switches
- 1x (or 2x depending on your needs) 5V laser diodes
- 1x 12V blinking light

## Building the firmware

Expand All @@ -90,72 +94,107 @@ You can also take a `.bin` file and upload it through the ElegantOTA interface a

Production files can be found in the [gerber](/gerber) folder of this repository.

The design fits on a 100x100mm PCB, so you should be able to get it built really cheap by online suppliers.
The design fits on a 100x100mm PCB, so you should be able to get it built for really cheap by online suppliers.

## Wiring

Coming soon™

## Status API
## Status APIs

A status API is available at `http://<YOUR_PANEL_IP>/status`.
### System/firmware information

It should return a JSON object similar to the following snippet:
```
GET http://<YOUR_PANEL_IP>/api/info
```

```json
{
"firmware": {
"version": "9da28a82",
"build_date": "Apr 30 2023 18:31:43"
},
"sensors": {
"voltages": {
"v1": 4.900000095,
"v2": 12.10000038,
"v3": 18
},
"cooling": {
"flow": 5.619999886,
"temp": 18.89999962
},
"lids": {
"front": "opened",
"back": "closed"
"firmware": {
"version": "9da28a82",
"build_date": "Apr 30 2023 18:31:43"
},
"flame_sensor": {
"triggered": false
"system": {
"chip": {
"model": "ESP32-D0WDQ5",
"revision": 1
},
"heap": {
"free": 80268,
"total": 257148
},
"cpu": {
"freq_mhz": 240,
"load_percent": {
"core_0": 0,
"core_1": 0.100000001
}
}
}
},
"alerts": {
"voltages": true,
"cooling": false,
"lids": true,
"flame_sensor": false
},
"relays": {
"laser": false,
"air_assist": true,
"cooling": true,
"alarm": false,
"lights": true,
"beam_preview": true
},
"system": {
"chip": {
"model": "ESP32-D0WDQ5",
"revision": 1
},
"heap": {
"free": 80268,
"total": 257148
},
"cpu": {
"freq_mhz": 240,
"load_percent": {
"core_0": 0,
"core_1": 0.100000001
}
}
```

### Sensors status

```
GET http://<YOUR_PANEL_IP>/api/sensors
```

```json
{
"sensors": {
"voltages": {
"v1": 4.900000095,
"v2": 12.10000038,
"v3": 18
},
"cooling": {
"flow": 5.619999886,
"temp": 18.89999962
},
"lids": {
"front": "opened",
"back": "closed"
},
"flame_sensor": {
"triggered": false
}
}
}
```

### Alerts state

```
GET http://<YOUR_PANEL_IP>/api/alerts
```

```json
{
"alerts": {
"voltages": true,
"cooling": false,
"lids": true,
"flame_sensor": false
}
}
```

### Relays activation state

```
GET http://<YOUR_PANEL_IP>/api/relays
```

```json
{
"relays": {
"laser": false,
"air_assist": true,
"cooling": true,
"alarm": false,
"lights": true,
"beam_preview": true
}
}
}
```
10 changes: 0 additions & 10 deletions include/K40/relays.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,6 @@ enum RelayPin {
PIN_RELAY_BEAM_PREVIEW = 26
};

typedef struct RelaysStatus RelaysStatus;
struct RelaysStatus {
bool laser_enabled;
bool air_assist_enabled;
bool cooling_enabled;
bool alarm_enabled;
bool lights_enabled;
bool beam_preview_enabled;
};

typedef struct RelaysCommand RelaysCommand;
struct RelaysCommand {
RelayPin pin;
Expand Down
3 changes: 1 addition & 2 deletions include/LVGL/lv_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
*=========================*/

/*1: use custom malloc/free, 0: use the built-in `lv_mem_alloc()` and `lv_mem_free()`*/
#define LV_MEM_CUSTOM 1
#define LV_MEM_CUSTOM 0
#if LV_MEM_CUSTOM == 0
/*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/
#define LV_MEM_SIZE (48U * 1024U) /*[bytes]*/
Expand Down Expand Up @@ -391,7 +391,6 @@
#define LV_FONT_CUSTOM_DECLARE \
LV_FONT_DECLARE(font_default_12) \
LV_FONT_DECLARE(font_default_14) \
LV_FONT_DECLARE(font_default_16) \
LV_FONT_DECLARE(font_icons_40)

/*Always set a default font*/
Expand Down
2 changes: 1 addition & 1 deletion include/UI/screens/bed.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
extern lv_obj_t *ui_bed_screen;

void ui_bed_init();
void ui_bed_update();
void ui_bed_update(bool initialize = false);

#endif
7 changes: 1 addition & 6 deletions include/UI/screens/controls.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@
#define CONTROLS_STATE_UPDATE_INTERVAL 500 // ms

extern lv_obj_t *ui_controls_screen;
extern lv_obj_t *ui_controls_laser_switch;
extern lv_obj_t *ui_controls_air_assist_switch;
extern lv_obj_t *ui_controls_cooling_switch;
extern lv_obj_t *ui_controls_lights_switch;
extern lv_obj_t *ui_controls_preview_switch;

void ui_controls_init();
void ui_controls_update();
void ui_controls_update(bool initialize = false);

#endif
4 changes: 1 addition & 3 deletions include/UI/screens/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
#define SETTINGS_STATE_UPDATE_INTERVAL 500 // ms

extern lv_obj_t *ui_settings_screen;
extern lv_obj_t *ui_settings_wifi_ssid_value;
extern lv_obj_t *ui_settings_wifi_connect_button;

void ui_settings_init();
void ui_settings_update();
void ui_settings_update(bool initialize = false);

#endif
2 changes: 1 addition & 1 deletion include/UI/screens/status.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ enum StatusUpdateType {
extern lv_obj_t *ui_status_screen;

void ui_status_init();
void ui_status_update();
void ui_status_update(bool initialize = false);
void ui_status_notify_update(uint8_t update_types);

#endif
14 changes: 0 additions & 14 deletions include/api.h

This file was deleted.

0 comments on commit 6476019

Please sign in to comment.