Skip to content

Commit

Permalink
Added a version of the fant hub firmware where it is default off
Browse files Browse the repository at this point in the history
  • Loading branch information
hmaarrfk committed Jan 5, 2025
1 parent 1a91d75 commit fe4d7b3
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
10 changes: 10 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,13 @@ build_src_filter =
+<*.hpp>
-<examples/**>
+<examples/fan_hub/*>

[env:teensy40_fan_hub_default_off]
extends = env:teensy40
build_src_filter =
+<*.c>
+<*.h>
+<*.cpp>
+<*.hpp>
-<examples/**>
+<examples/fan_hub_default_off/*>
66 changes: 66 additions & 0 deletions src/examples/fan_hub_default_off/fan_hub.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/* A small demo to show how the teensy-to-any can be used to control 4 pin fans.
* It is assumed that the fan PWM pin is connected to pin 2
* and that an indicator LED is connected to Pin 13 (this is the default board)
*
* The demo code will run the fan at
* * 100%
* * 75%
* * 50%
* * 25%
* * 0%
* For 3 seconds at a time and then continue in an infinite loop.
* The LED can be used as a visual guide of the expected speed of the fan.
*
* Not all fan will be able to operate at 25% duty cyle.
*
* Ramona Optics - 2024
*/
const char *teensy_to_any_startup_commands[] = {
// Setup the LED as an indicator pin
"gpio_pin_mode 13 OUTPUT 1",
// Setup pin 2 as the PWM control pin
"gpio_pin_mode 2 OUTPUT 1",
// Set the frequency to 25 kHz
"analog_write_frequency 2 25000",
// Also setup the LED to tell us what is going on.
"analog_write_frequency 13 25000",
"analog_write 2 0",
"analog_write 13 0",
nullptr,
};

// Change the fan speed
const char *teensy_to_any_demo_commands[] = {
// "analog_write 2 255",
// "analog_write 13 255",
// "sleep 0.2", "sleep 0.2", "sleep 0.2", "sleep 0.2", "sleep 0.2", // 1000 ms
// "sleep 0.2", "sleep 0.2", "sleep 0.2", "sleep 0.2", "sleep 0.2", // 1000 ms
// "sleep 0.2", "sleep 0.2", "sleep 0.2", "sleep 0.2", "sleep 0.2", // 1000 ms

// "analog_write 2 192",
// // Brightness is a strange thing, and does not
// // decrease so linearly according to human perception
// "analog_write 13 128",
// "sleep 0.2", "sleep 0.2", "sleep 0.2", "sleep 0.2", "sleep 0.2", // 1000 ms
// "sleep 0.2", "sleep 0.2", "sleep 0.2", "sleep 0.2", "sleep 0.2", // 1000 ms
// "sleep 0.2", "sleep 0.2", "sleep 0.2", "sleep 0.2", "sleep 0.2", // 1000 ms

// "analog_write 2 128",
// "analog_write 13 30",
// "sleep 0.2", "sleep 0.2", "sleep 0.2", "sleep 0.2", "sleep 0.2", // 1000 ms
// "sleep 0.2", "sleep 0.2", "sleep 0.2", "sleep 0.2", "sleep 0.2", // 1000 ms
// "sleep 0.2", "sleep 0.2", "sleep 0.2", "sleep 0.2", "sleep 0.2", // 1000 ms

// "analog_write 2 64",
// "analog_write 13 10",
// "sleep 0.2", "sleep 0.2", "sleep 0.2", "sleep 0.2", "sleep 0.2", // 1000 ms
// "sleep 0.2", "sleep 0.2", "sleep 0.2", "sleep 0.2", "sleep 0.2", // 1000 ms
// "sleep 0.2", "sleep 0.2", "sleep 0.2", "sleep 0.2", "sleep 0.2", // 1000 ms

// "analog_write 2 0",
// "analog_write 13 0",
// "sleep 0.2", "sleep 0.2", "sleep 0.2", "sleep 0.2", "sleep 0.2", // 1000 ms
// "sleep 0.2", "sleep 0.2", "sleep 0.2", "sleep 0.2", "sleep 0.2", // 1000 ms
// "sleep 0.2", "sleep 0.2", "sleep 0.2", "sleep 0.2", "sleep 0.2", // 1000 ms
nullptr,
};

0 comments on commit fe4d7b3

Please sign in to comment.