Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
hddtempserial
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Oleg Nikulin
hddtempserial
Commits
312fe2d1
Commit
312fe2d1
authored
Jun 26, 2023
by
Oleg Nikulin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Температура перегрева указывается в конфиге
parent
ba51fec0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
8 deletions
+26
-8
config.json
config.json
+3
-0
hddtempserial.py
hddtempserial.py
+6
-0
hddtempserial.ino
hddtempserial/hddtempserial.ino
+17
-8
No files found.
config.json
View file @
312fe2d1
...
...
@@ -7,14 +7,17 @@
[
{
"targetTemperature"
:
35
,
"overheatTemperature"
:
60
,
"copyFromGroupIndex"
:
255
},
{
"targetTemperature"
:
40
,
"overheatTemperature"
:
60
,
"copyFromGroupIndex"
:
255
},
{
"targetTemperature"
:
45
,
"overheatTemperature"
:
60
,
"copyFromGroupIndex"
:
255
}
...
...
hddtempserial.py
View file @
312fe2d1
...
...
@@ -62,9 +62,15 @@ def initialize(serial_port):
transmit_bytes
=
[
pc_command_codes
.
initialize
,
config
[
'pollIntervalSec'
],
config
[
'controlGroups'
][
0
][
'targetTemperature'
],
config
[
'controlGroups'
][
1
][
'targetTemperature'
],
config
[
'controlGroups'
][
2
][
'targetTemperature'
],
config
[
'controlGroups'
][
0
][
'overheatTemperature'
],
config
[
'controlGroups'
][
1
][
'overheatTemperature'
],
config
[
'controlGroups'
][
2
][
'overheatTemperature'
],
config
[
'controlGroups'
][
0
][
'copyFromGroupIndex'
],
config
[
'controlGroups'
][
1
][
'copyFromGroupIndex'
],
config
[
'controlGroups'
][
2
][
'copyFromGroupIndex'
]
...
...
hddtempserial/hddtempserial.ino
View file @
312fe2d1
...
...
@@ -21,7 +21,7 @@
#define SOUND_PIN 10 //Номер пина пищалки
#define LED_PIN 13 //Номер пина светодиода
#define OVERHEAT_TEMP 75 //Температура, при достижении которой включается пищалка //TODO получать при инициализации
typedef
int16_t
temp_t
;
uint16_t
*
control_a_addr
=
0x88
;
//адрес сравнения А таймера 1
uint16_t
*
control_b_addr
=
0xB3
;
//адрес сравнения А таймера 2
...
...
@@ -37,8 +37,9 @@ struct control {//Данные о группе управления
uint8_t
pin
;
//Номер пина
volatile
control_pwm_mode
mode
;
//Текущий режим ШИМ
uint16_t
&
dutyCycle
;
//Скважность ШИМ
int16_t
temperature
;
//Текущая температура
int16_t
target_temperature
;
//Температура, к которой нужно стремиться
temp_t
temperature
;
//Текущая температура
temp_t
overheat_temperature
;
//Температура >= этой считается перегревом
temp_t
target_temperature
;
//Температура, к которой нужно стремиться
int8_t
copy_from
;
//Копировать скважность с другой группы управления. -1 = не копировать, 0 = с группы A, 1 = с группы B, 2 = с группы C
};
...
...
@@ -48,6 +49,7 @@ control controls[CONTROL_COUNT] = {
control_pwm_mode
::
off
,
*
control_a_addr
,
0
,
60
,
0
,
-
1
},
...
...
@@ -56,6 +58,7 @@ control controls[CONTROL_COUNT] = {
control_pwm_mode
::
off
,
*
control_b_addr
,
0
,
60
,
0
,
0
},
...
...
@@ -64,6 +67,7 @@ control controls[CONTROL_COUNT] = {
control_pwm_mode
::
off
,
*
control_c_addr
,
0
,
60
,
0
,
0
}
...
...
@@ -204,7 +208,7 @@ void process_command() {
//по коду команды понимаем длину команды (с учетом байта кода команды и двух байт crc)
switch
(
cmd_code
)
{
case
pc_command_codes
:
:
initialize
:
cmd_length
=
1
0
;
cmd_length
=
1
3
;
break
;
case
pc_command_codes
:
:
poll
:
cmd_length
=
9
;
...
...
@@ -231,9 +235,14 @@ void process_command() {
control_a
.
target_temperature
=
cmd_buffer
[
2
];
control_b
.
target_temperature
=
cmd_buffer
[
3
];
control_c
.
target_temperature
=
cmd_buffer
[
4
];
control_a
.
copy_from
=
cmd_buffer
[
5
];
control_b
.
copy_from
=
cmd_buffer
[
6
];
control_c
.
copy_from
=
cmd_buffer
[
7
];
control_a
.
overheat_temperature
=
cmd_buffer
[
5
];
control_b
.
overheat_temperature
=
cmd_buffer
[
6
];
control_c
.
overheat_temperature
=
cmd_buffer
[
7
];
control_a
.
copy_from
=
cmd_buffer
[
8
];
control_b
.
copy_from
=
cmd_buffer
[
9
];
control_c
.
copy_from
=
cmd_buffer
[
10
];
initialized
=
true
;
...
...
@@ -470,7 +479,7 @@ void loop() {
pc_respond
=
false
;
}
if
(
control_a
.
temperature
>=
OVERHEAT_TEMP
||
control_b
.
temperature
>=
OVERHEAT_TEMP
||
control_c
.
temperature
>=
OVERHEAT_TEMP
)
{
//Если перегрев, включается пищалка
if
(
control_a
.
temperature
>=
control_a
.
overheat_temperature
||
control_b
.
temperature
>=
control_b
.
overheat_temperature
||
control_c
.
temperature
>=
control_c
.
overheat_temperature
)
{
//Если перегрев, включается пищалка
if
(
millis
()
>=
last_beep_time
+
BEEP_INTERVAL
*
2
)
{
analogWrite
(
SOUND_PIN
,
BEEP_STRENGTH
);
last_beep_time
=
millis
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment