Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
constants.h
Go to the documentation of this file.
1
5#ifndef USER_CONSTANTS_H
6#define USER_CONSTANTS_H
7
8//
9// hardware gates, common to all lamp types (preprocessor only: also read by the C drivers)
10//
11
20#ifdef LMBD_USBC_HAS_BOARD_CC_RD
21#error "LMBD_USBC_HAS_BOARD_CC_RD must be set in src/user/constants.h, not in the build flags"
22#endif
23#define LMBD_USBC_HAS_BOARD_CC_RD 1
24
25// the rest of this file is C++ only
26#ifdef __cplusplus
27
28#include <cstdint>
29#include <cmath>
30
31namespace lampda {
32
33//
34// common to all lamp type
35//
36
37// does button usermode defaults to "lockdown" mode?
38static constexpr bool usermodeDefaultsToLockdown = false;
39
40static constexpr float c_PI = 3.1415926535897f;
41static constexpr float c_TWO_PI = 6.2831853071795f;
42static constexpr float c_HALF_PI = 1.5707963267948f;
43
44static constexpr float c_degreesToRadians = c_PI / 180.0f;
45// Update when the soft changes version
46static constexpr uint8_t USER_SOFTWARE_VERSION_MAJOR = 1;
47static constexpr uint8_t USER_SOFTWARE_VERSION_MINOR = 10;
48
49//
50// simple lamp type
51//
52
53#ifdef LMBD_LAMP_TYPE__SIMPLE
54
55// compute the expected average loop runtime (in ms)
56// defined as milliseconds / FPS
57static constexpr uint32_t MAIN_LOOP_UPDATE_PERIOD_MS = static_cast<uint32_t>(1000 / 80.0f);
58
59// parameters of the led strip used
60static constexpr float consWattByMeter = 12; // power consumption (in Watt/meters)
61static constexpr uint16_t stripInputMinVoltage_mV = 9400; // min allowed voltage
62static constexpr uint16_t stripInputMaxVoltage_mV = 12000; // max allowed voltage
63static constexpr float ledStripLength_mm = 91.0f * 25.0f; // 91 sections of 25 mm
64
65// define position of led 0 to the circuit center
66static constexpr float circuitToLedZeroRotationX_degrees = 0.0f;
67static constexpr float circuitToLedZeroRotationY_degrees = 0.0f;
68static constexpr float circuitToLedZeroRotationZ_degrees = 88.0f;
69
70#endif // LMBD_LAMP_TYPE__SIMPLE
71
72//
73// cct lamp type
74//
75
76#ifdef LMBD_LAMP_TYPE__CCT
77
78// compute the expected average loop runtime (in ms)
79// defined as milliseconds / FPS
80static constexpr uint32_t MAIN_LOOP_UPDATE_PERIOD_MS = static_cast<uint32_t>(1000 / 80.0f);
81
82// parameters of the led strip used
83static constexpr float consWattByMeter = 10; // power consumption (in Watt/meters)
84static constexpr uint16_t stripInputMinVoltage_mV = 9000; // min allowed led voltage
85static constexpr uint16_t stripInputMaxVoltage_mV = 12000; // min allowed led voltage
86static constexpr float ledStripLength_mm = 67.0f * 27.0f; // 67 sections of 27 mm
87
88// define position of led 0 to the circuit center
89static constexpr float circuitToLedZeroRotationX_degrees = 0.0f;
90static constexpr float circuitToLedZeroRotationY_degrees = 0.0f;
91static constexpr float circuitToLedZeroRotationZ_degrees = 88.0f;
92
93#endif // LMBD_LAMP_TYPE__CCT
94
95//
96// indexable lamp type
97//
98
99#ifdef LMBD_LAMP_TYPE__INDEXABLE
100static constexpr float lampBodyRadius_mm = 25; // external radius of the lamp body
101
102// parameters of the led strip used
103#ifdef LMBD_LAMP_TYPE__INDEXABLE_IS_HD
104// hd 240L/m strip
105static constexpr uint16_t LED_COUNT = 870; // How many indexable leds are attached to the controler
106static constexpr float consWattByMeter = 5; // power consumption (in Watt/meters)
107static constexpr uint16_t stripInputMinVoltage_mV = 12000; // min allowed voltage
108static constexpr uint16_t stripInputMaxVoltage_mV = 12000; // max allowed voltage
109static constexpr float ledByMeter = 244; // the REAL indexable led by meters (for a 240Led/m)
110static constexpr float ledStripWidth_mm = 5.2f; // width of the led strip
111static constexpr float ledStripHeigh_mm = 0.7f; // heigh of the led strip (calibrated for this strip)
112static constexpr uint8_t minimumAllowedBrightness_8 = 3; // minium allowed brightnes level,0-255
113
114// compute the expected average loop runtime (in ms)
115// defined as milliseconds / FPS
116static constexpr uint32_t MAIN_LOOP_UPDATE_PERIOD_MS = static_cast<uint32_t>(1000 / 40.0f);
117#else
118// standard 160L/m strip
119static constexpr uint16_t LED_COUNT = 580; // How many indexable leds are attached to the controler
120static constexpr float consWattByMeter = 5; // power consumption (in Watt/meters)
121static constexpr uint16_t stripInputMinVoltage_mV = 12000; // min allowed voltage
122static constexpr uint16_t stripInputMaxVoltage_mV = 12000; // max allowed voltage
123static constexpr float ledByMeter = 162.6f; // the REAL indexable led by meters (for a 160Led/m)
124static constexpr float ledStripWidth_mm = 5.2f; // width of the led strip
125static constexpr float ledStripHeigh_mm = 0.7f; // heigh of the led strip (calibrated for this strip)
126static constexpr uint8_t minimumAllowedBrightness_8 = 3; // minium allowed brightnes level,0-255
127
128// compute the expected average loop runtime (in ms)
129// defined as milliseconds / FPS
130static constexpr uint32_t MAIN_LOOP_UPDATE_PERIOD_MS = static_cast<uint32_t>(1000 / 80.0f);
131#endif
132
133// physical parameters computations
134static constexpr float ledSize_mm = 1000.0f / ledByMeter; // size of the individual led
135static constexpr float lampBodyCircumpherence_mm = c_TWO_PI * lampBodyRadius_mm; // external circumpherence
136static constexpr float ledStripLength_mm = LED_COUNT * ledSize_mm;
137
138// led per tube circumpherence
139static constexpr float ledPerTurn = lampBodyCircumpherence_mm / ledSize_mm;
140// estimate of the lamp height
141static constexpr float lampHeight = ledStripWidth_mm * LED_COUNT / ledPerTurn;
142
143static constexpr float stripXCoordinates = lampBodyCircumpherence_mm / ledSize_mm;
144static constexpr float stripYCoordinates = ledStripLength_mm / lampBodyCircumpherence_mm;
145static constexpr float lampBodyHeight_mm = stripYCoordinates * ledStripWidth_mm;
146
147constexpr uint16_t stripMatrixWidth = ceil(stripXCoordinates);
148constexpr uint16_t stripMatrixHeight = ceil(stripYCoordinates);
149
150// define position of led 0 to the circuit center
151static constexpr float circuitToLedZeroRotationX_degrees = 0.0f;
152static constexpr float circuitToLedZeroRotationY_degrees = 0.0f;
153static constexpr float circuitToLedZeroRotationZ_degrees = 88.0f;
154
155#endif // LMBD_LAMP_TYPE__INDEXABLE
156
157//
158// add your own lamp type below :)
159//
160
161} // namespace lampda
162
163#endif // __cplusplus
164
165#endif
Program scope.
Definition: control_fixed_modes.hpp:14
static constexpr float c_PI
PI constant.
Definition: constants.h:40
static constexpr float c_degreesToRadians
convert degrees to radians
Definition: constants.h:44
static constexpr float c_TWO_PI
2*PI constant
Definition: constants.h:41
static constexpr float c_HALF_PI
PI/2 constant.
Definition: constants.h:42