Skip to content

Commit ec332c4

Browse files
authored
Merge pull request #735 from recrof/t1000_refactor
t1000 cleanup + move NullDisplayDriver.h out of t1000e folder
2 parents 6fae950 + 9b9c728 commit ec332c4

File tree

5 files changed

+107
-150
lines changed

5 files changed

+107
-150
lines changed
File renamed without changes.

variants/t1000-e/T1000eBoard.h

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,6 @@
33
#include <MeshCore.h>
44
#include <Arduino.h>
55

6-
// LoRa and SPI pins
7-
#define P_LORA_DIO_1 (32 + 1) // P1.1
8-
#define P_LORA_NSS (0 + 12) // P0.12
9-
#define P_LORA_RESET (32 + 10) // P1.10
10-
#define P_LORA_BUSY (0 + 7) // P0.7
11-
#define P_LORA_SCLK (0 + 11) // P0.11
12-
#define P_LORA_MISO (32 + 8) // P1.8
13-
#define P_LORA_MOSI (32 + 9) // P0.9
14-
15-
#define LR11X0_DIO_AS_RF_SWITCH true
16-
#define LR11X0_DIO3_TCXO_VOLTAGE 1.6
17-
18-
// built-ins
19-
//#define PIN_VBAT_READ 5
20-
//#define ADC_MULTIPLIER (3 * 1.73 * 1000)
21-
226
class T1000eBoard : public mesh::MainBoard {
237
protected:
248
uint8_t startup_reason;
@@ -75,11 +59,11 @@ class T1000eBoard : public mesh::MainBoard {
7559
pinMode(GPS_RESETB, OUTPUT);
7660
digitalWrite(GPS_RESETB, LOW);
7761
#endif
78-
62+
7963
#ifdef BUZZER_EN
8064
digitalWrite(BUZZER_EN, LOW);
8165
#endif
82-
66+
8367
#ifdef PIN_3V3_EN
8468
digitalWrite(PIN_3V3_EN, LOW);
8569
#endif

variants/t1000-e/platformio.ini

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,32 @@
1-
; ----------------- NRF52 T1000e---------------------
2-
[nrf52840_t1000e]
1+
[t1000-e]
32
extends = nrf52_base
4-
platform_packages = framework-arduinoadafruitnrf52
3+
board = tracker-t1000-e
4+
board_build.ldscript = boards/nrf52840_s140_v7.ld
55
build_flags = ${nrf52_base.build_flags}
66
-I src/helpers/nrf52
77
-I lib/nrf52/s140_nrf52_7.3.0_API/include
88
-I lib/nrf52/s140_nrf52_7.3.0_API/include/nrf52
9-
lib_ignore =
10-
BluetoothOTA
11-
lvgl
12-
lib5b4
13-
lib_deps =
14-
${nrf52_base.lib_deps}
15-
rweather/Crypto @ ^0.4.0
16-
17-
[t1000-e]
18-
extends = nrf52840_t1000e
19-
board = tracker-t1000-e
20-
board_build.ldscript = boards/nrf52840_s140_v7.ld
21-
build_flags = ${nrf52840_t1000e.build_flags}
229
-I variants/t1000-e
10+
-I src/helpers/ui
2311
-D T1000_E
2412
-D PIN_USER_BTN=6
2513
-D USER_BTN_PRESSED=HIGH
2614
-D PIN_STATUS_LED=24
2715
-D RADIO_CLASS=CustomLR1110
2816
-D WRAPPER_CLASS=CustomLR1110Wrapper
2917
-D LORA_TX_POWER=22
30-
build_src_filter = ${nrf52840_t1000e.build_src_filter}
18+
-D RF_SWITCH_TABLE
19+
-D RX_BOOSTED_GAIN=true
20+
-D P_LORA_BUSY=7 ; P0.7
21+
-D P_LORA_SCLK=11 ; P0.11
22+
-D P_LORA_NSS=12 ; P0.12
23+
-D P_LORA_DIO_1=33 ; P1.1
24+
-D P_LORA_MISO=40 ; P1.8
25+
-D P_LORA_MOSI=41 ; P0.9
26+
-D P_LORA_RESET=42 ; P1.10
27+
-D LR11X0_DIO_AS_RF_SWITCH=true
28+
-D LR11X0_DIO3_TCXO_VOLTAGE=1.6
29+
build_src_filter = ${nrf52_base.build_src_filter}
3130
+<helpers/*.cpp>
3231
+<helpers/nrf52/T1000eBoard.cpp>
3332
+<../variants/t1000-e>
@@ -45,8 +44,6 @@ build_flags = ${t1000-e.build_flags}
4544
-D MAX_NEIGHBOURS=8
4645
; -D MESH_PACKET_LOGGING=1
4746
; -D MESH_DEBUG=1
48-
-D RX_BOOSTED_GAIN=true
49-
-D RF_SWITCH_TABLE
5047
build_src_filter = ${t1000-e.build_src_filter}
5148
+<../examples/simple_repeater>
5249
lib_deps = ${t1000-e.lib_deps}
@@ -63,7 +60,6 @@ build_flags = ${t1000-e.build_flags}
6360
-D ROOM_PASSWORD='"hello"'
6461
; -D MESH_PACKET_LOGGING=1
6562
; -D MESH_DEBUG=1
66-
-D RX_BOOSTED_GAIN=true
6763
-D RF_SWITCH_TABLE
6864
build_src_filter = ${t1000-e.build_src_filter}
6965
+<../examples/simple_room_server>
@@ -79,8 +75,6 @@ build_flags = ${t1000-e.build_flags}
7975
; -D MESH_PACKET_LOGGING=1
8076
; -D MESH_DEBUG=1
8177
-D OFFLINE_QUEUE_SIZE=256
82-
-D RX_BOOSTED_GAIN=true
83-
-D RF_SWITCH_TABLE
8478
-D DISPLAY_CLASS=NullDisplayDriver
8579
-D PIN_BUZZER=25
8680
-D PIN_BUZZER_EN=37 ; P1/5 - required for T1000-E
@@ -104,8 +98,6 @@ build_flags = ${t1000-e.build_flags}
10498
; -D MESH_PACKET_LOGGING=1
10599
; -D MESH_DEBUG=1
106100
-D OFFLINE_QUEUE_SIZE=256
107-
-D RX_BOOSTED_GAIN=true
108-
-D RF_SWITCH_TABLE
109101
-D DISPLAY_CLASS=NullDisplayDriver
110102
-D PIN_BUZZER=25
111103
-D PIN_BUZZER_EN=37 ; P1/5 - required for T1000-E
Lines changed: 87 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,99 @@
1-
#include <Arduino.h>
21
#include "t1000e_sensors.h"
32

4-
#define HEATER_NTC_BX 4250 // thermistor coefficient B
5-
#define HEATER_NTC_RP 8250 // ohm, series resistance to thermistor
6-
#define HEATER_NTC_KA 273.15 // 25 Celsius at Kelvin
7-
#define NTC_REF_VCC 3000 // mV, output voltage of LDO
8-
#define LIGHT_REF_VCC 2400 //
9-
10-
static unsigned int ntc_res2[136]={
11-
113347,107565,102116,96978,92132,87559,83242,79166,75316,71677,
12-
68237,64991,61919,59011,56258,53650,51178,48835,46613,44506,
13-
42506,40600,38791,37073,35442,33892,32420,31020,29689,28423,
14-
27219,26076,24988,23951,22963,22021,21123,20267,19450,18670,
15-
17926,17214,16534,15886,15266,14674,14108,13566,13049,12554,
16-
12081,11628,11195,10780,10382,10000,9634,9284,8947,8624,
17-
8315,8018,7734,7461,7199,6948,6707,6475,6253,6039,
18-
5834,5636,5445,5262,5086,4917,4754,4597,4446,4301,
19-
4161,4026,3896,3771,3651,3535,3423,3315,3211,3111,
20-
3014,2922,2834,2748,2666,2586,2509,2435,2364,2294,
21-
2228,2163,2100,2040,1981,1925,1870,1817,1766,1716,
22-
1669,1622,1578,1535,1493,1452,1413,1375,1338,1303,
23-
1268,1234,1202,1170,1139,1110,1081,1053,1026,999,
24-
974,949,925,902,880,858,
3+
#include <Arduino.h>
4+
5+
#define HEATER_NTC_BX 4250 // thermistor coefficient B
6+
#define HEATER_NTC_RP 8250 // ohm, series resistance to thermistor
7+
#define HEATER_NTC_KA 273.15 // 25 Celsius at Kelvin
8+
#define NTC_REF_VCC 3000 // mV, output voltage of LDO
9+
#define LIGHT_REF_VCC 2400 //
10+
11+
static unsigned int ntc_res2[136] = {
12+
113347, 107565, 102116, 96978, 92132, 87559, 83242, 79166, 75316, 71677, 68237, 64991, 61919, 59011,
13+
56258, 53650, 51178, 48835, 46613, 44506, 42506, 40600, 38791, 37073, 35442, 33892, 32420, 31020,
14+
29689, 28423, 27219, 26076, 24988, 23951, 22963, 22021, 21123, 20267, 19450, 18670, 17926, 17214,
15+
16534, 15886, 15266, 14674, 14108, 13566, 13049, 12554, 12081, 11628, 11195, 10780, 10382, 10000,
16+
9634, 9284, 8947, 8624, 8315, 8018, 7734, 7461, 7199, 6948, 6707, 6475, 6253, 6039,
17+
5834, 5636, 5445, 5262, 5086, 4917, 4754, 4597, 4446, 4301, 4161, 4026, 3896, 3771,
18+
3651, 3535, 3423, 3315, 3211, 3111, 3014, 2922, 2834, 2748, 2666, 2586, 2509, 2435,
19+
2364, 2294, 2228, 2163, 2100, 2040, 1981, 1925, 1870, 1817, 1766, 1716, 1669, 1622,
20+
1578, 1535, 1493, 1452, 1413, 1375, 1338, 1303, 1268, 1234, 1202, 1170, 1139, 1110,
21+
1081, 1053, 1026, 999, 974, 949, 925, 902, 880, 858,
2522
};
26-
27-
static char ntc_temp2[136]=
28-
{
29-
-30,-29,-28,-27,-26,-25,-24,-23,-22,-21,
30-
-20,-19,-18,-17,-16,-15,-14,-13,-12,-11,
31-
-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,
32-
0,1,2,3,4,5,6,7,8,9,
33-
10,11,12,13,14,15,16,17,18,19,
34-
20,21,22,23,24,25,26,27,28,29,
35-
30,31,32,33,34,35,36,37,38,39,
36-
40,41,42,43,44,45,46,47,48,49,
37-
50,51,52,53,54,55,56,57,58,59,
38-
60,61,62,63,64,65,66,67,68,69,
39-
70,71,72,73,74,75,76,77,78,79,
40-
80,81,82,83,84,85,86,87,88,89,
41-
90,91,92,93,94,95,96,97,98,99,
42-
100,101,102,103,104,105,
23+
24+
static char ntc_temp2[136] = {
25+
-30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11,
26+
-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
27+
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
28+
30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
29+
50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
30+
70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
31+
90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
4332
};
4433

45-
static float get_heater_temperature( unsigned int vcc_volt, unsigned int ntc_volt )
46-
{
47-
int i = 0;
48-
float Vout = 0, Rt = 0, temp = 0;
49-
Vout = ntc_volt;
50-
51-
Rt = ( HEATER_NTC_RP * vcc_volt ) / Vout - HEATER_NTC_RP;
52-
53-
for( i = 0; i < 136; i++ )
54-
{
55-
if( Rt >= ntc_res2[i] )
56-
{
57-
break;
58-
}
34+
static float get_heater_temperature(unsigned int vcc_volt, unsigned int ntc_volt) {
35+
int i = 0;
36+
float Vout = 0, Rt = 0, temp = 0;
37+
Vout = ntc_volt;
38+
39+
Rt = (HEATER_NTC_RP * vcc_volt) / Vout - HEATER_NTC_RP;
40+
41+
for (i = 0; i < 136; i++) {
42+
if (Rt >= ntc_res2[i]) {
43+
break;
5944
}
60-
61-
temp = ntc_temp2[i - 1] + 1 * ( ntc_res2[i - 1] - Rt ) / ( float )( ntc_res2[i - 1] - ntc_res2[i] );
62-
63-
temp = ( temp * 100 + 5 ) / 100;
64-
return temp;
45+
}
46+
47+
temp = ntc_temp2[i - 1] + 1 * (ntc_res2[i - 1] - Rt) / (float)(ntc_res2[i - 1] - ntc_res2[i]);
48+
49+
temp = (temp * 100 + 5) / 100;
50+
return temp;
6551
}
6652

67-
static int get_light_lv( unsigned int light_volt )
68-
{
69-
float Vout = 0, Vin = 0, Rt = 0, temp = 0;
70-
unsigned int light_level = 0;
71-
72-
if( light_volt <= 80 )
73-
{
74-
light_level = 0;
75-
return light_level;
76-
}
77-
else if( light_volt >= 2480 )
78-
{
79-
light_level = 100;
80-
return light_level;
81-
}
82-
Vout = light_volt;
83-
light_level = 100 * ( Vout - 80 ) / LIGHT_REF_VCC;
84-
53+
static int get_light_lv(unsigned int light_volt) {
54+
float Vout = 0, Vin = 0, Rt = 0, temp = 0;
55+
unsigned int light_level = 0;
56+
57+
if (light_volt <= 80) {
58+
light_level = 0;
59+
return light_level;
60+
} else if (light_volt >= 2480) {
61+
light_level = 100;
8562
return light_level;
86-
}
87-
88-
float t1000e_get_temperature( void )
89-
{
90-
unsigned int ntc_v, vcc_v;
91-
92-
digitalWrite(PIN_3V3_EN, HIGH);
93-
digitalWrite(SENSOR_EN, HIGH);
94-
analogReference(AR_INTERNAL_3_0);
95-
analogReadResolution(12);
96-
delay(10);
97-
vcc_v = (1000.0*(analogRead(BATTERY_PIN) * ADC_MULTIPLIER * AREF_VOLTAGE)) / 4096;
98-
ntc_v = (1000.0 * AREF_VOLTAGE * analogRead(TEMP_SENSOR)) / 4096;
99-
digitalWrite(PIN_3V3_EN, LOW);
100-
digitalWrite(SENSOR_EN, LOW);
101-
102-
return get_heater_temperature (vcc_v, ntc_v);
63+
}
64+
Vout = light_volt;
65+
light_level = 100 * (Vout - 80) / LIGHT_REF_VCC;
66+
67+
return light_level;
68+
}
69+
70+
float t1000e_get_temperature(void) {
71+
unsigned int ntc_v, vcc_v;
72+
73+
digitalWrite(PIN_3V3_EN, HIGH);
74+
digitalWrite(SENSOR_EN, HIGH);
75+
analogReference(AR_INTERNAL_3_0);
76+
analogReadResolution(12);
77+
delay(10);
78+
vcc_v = (1000.0 * (analogRead(BATTERY_PIN) * ADC_MULTIPLIER * AREF_VOLTAGE)) / 4096;
79+
ntc_v = (1000.0 * AREF_VOLTAGE * analogRead(TEMP_SENSOR)) / 4096;
80+
digitalWrite(PIN_3V3_EN, LOW);
81+
digitalWrite(SENSOR_EN, LOW);
82+
83+
return get_heater_temperature(vcc_v, ntc_v);
10384
}
10485

105-
uint32_t t1000e_get_light( void )
106-
{
107-
int lux = 0;
108-
unsigned int lux_v = 0;
109-
110-
digitalWrite(SENSOR_EN, HIGH);
111-
analogReference(AR_INTERNAL_3_0);
112-
analogReadResolution(12);
113-
delay(10);
114-
lux_v = 1000 * analogRead(LUX_SENSOR) * AREF_VOLTAGE / 4096;
115-
lux = get_light_lv( lux_v );
116-
digitalWrite(SENSOR_EN, LOW);
117-
118-
return lux;
86+
uint32_t t1000e_get_light(void) {
87+
int lux = 0;
88+
unsigned int lux_v = 0;
89+
90+
digitalWrite(SENSOR_EN, HIGH);
91+
analogReference(AR_INTERNAL_3_0);
92+
analogReadResolution(12);
93+
delay(10);
94+
lux_v = 1000 * analogRead(LUX_SENSOR) * AREF_VOLTAGE / 4096;
95+
lux = get_light_lv(lux_v);
96+
digitalWrite(SENSOR_EN, LOW);
97+
98+
return lux;
11999
}

variants/t1000-e/t1000e_sensors.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#pragma once
2+
#include <stdint.h>
23

34
// Light and temperature sensors are on ADC ports
4-
// functions adapted from Seeed examples to get values
5+
// functions adapted from Seeed examples to get values
56
// see : https://github.com/Seeed-Studio/Seeed-Tracker-T1000-E-for-LoRaWAN-dev-board
67

78
extern uint32_t t1000e_get_light();

0 commit comments

Comments
 (0)