Test with double-sided (2x4 modules) platform display

This commit is contained in:
Julian Metzler 2024-06-08 13:49:00 +02:00
parent 66879babe3
commit 5ab41a10b9
3 changed files with 44 additions and 15 deletions

View File

@ -3,13 +3,14 @@
module_status_t MODULE_STATUSES[NUM_MODULES] = {
{ .target = 0, .new_target = 0, .rotating = 0, .start_time = 0 },
{ .target = 0, .new_target = 0, .rotating = 0, .start_time = 0 },
{ .target = 0, .new_target = 0, .rotating = 0, .start_time = 0 },
{ .target = 0, .new_target = 0, .rotating = 0, .start_time = 0 },
{ .target = 0, .new_target = 0, .rotating = 0, .start_time = 0 },
{ .target = 0, .new_target = 0, .rotating = 0, .start_time = 0 },
{ .target = 0, .new_target = 0, .rotating = 0, .start_time = 0 }
{ .target = 0, .new_target = 0, .rotating = 0, .start_time = 0, .post_positioning_start_time = 0 },
{ .target = 0, .new_target = 0, .rotating = 0, .start_time = 0, .post_positioning_start_time = 0 },
{ .target = 0, .new_target = 0, .rotating = 0, .start_time = 0, .post_positioning_start_time = 0 },
{ .target = 0, .new_target = 0, .rotating = 0, .start_time = 0, .post_positioning_start_time = 0 },
{ .target = 0, .new_target = 0, .rotating = 0, .start_time = 0, .post_positioning_start_time = 0 },
{ .target = 0, .new_target = 0, .rotating = 0, .start_time = 0, .post_positioning_start_time = 0 },
{ .target = 0, .new_target = 0, .rotating = 0, .start_time = 0, .post_positioning_start_time = 0 },
{ .target = 0, .new_target = 0, .rotating = 0, .start_time = 0, .post_positioning_start_time = 0 }
};
@ -88,19 +89,26 @@ void splitflap_update() {
void splitflap_loop() {
for (uint8_t i = 0; i < NUM_MODULES; i++) {
uint32_t now = millis();
// Check status of every module
module_status_t module_status = MODULE_STATUSES[i];
if (!module_status.rotating) continue;
module_status_t* module_status = &MODULE_STATUSES[i];
if (!module_status->rotating) continue;
// Check for timeout
if (millis() - MODULE_STATUSES[i].start_time >= MODULE_TIMEOUT) {
if (now - module_status->start_time >= MODULE_TIMEOUT) {
// Timeout reached
splitflap_stop(i);
}
uint8_t pos = splitflap_readPos(i);
if (pos == module_status.target) {
if (pos == module_status->target && module_status->post_positioning_start_time == 0) {
module_status->post_positioning_start_time = now;
}
if (module_status->rotating && module_status->post_positioning_start_time != 0 && now - module_status->post_positioning_start_time >= POST_POSITIONING_DELAY) {
splitflap_stop(i);
module_status->post_positioning_start_time = 0;
}
}
}

View File

@ -1,4 +1,4 @@
#define NUM_MODULES 7
#define NUM_MODULES 8
// Gray code sensor inputs (Bits 1 to 6)
#define GRAY_1 32
@ -9,14 +9,14 @@
#define GRAY_6 37
// Modules: A1, A3, A4, B1, C1, D1, E1
const uint8_t SENS_EN_PINS[NUM_MODULES] = {4, 6, 8, 10, 22, 24, 26};
const uint8_t MOT_EN_PINS[NUM_MODULES] = {5, 7, 9, 11, 23, 25, 27};
const uint8_t SENS_EN_PINS[NUM_MODULES] = {4, 6, 8, 10, 22, 24, 26, 28};
const uint8_t MOT_EN_PINS[NUM_MODULES] = {5, 7, 9, 11, 23, 25, 27, 29};
// in µs
#define SENSOR_ENABLE_DELAY 100
// in ms
#define POST_POSITIONING_DELAY 10
#define POST_POSITIONING_DELAY 2
// in ms
#define MODULE_TIMEOUT 10000
@ -27,6 +27,7 @@ typedef struct module_status {
uint8_t new_target;
uint8_t rotating;
uint32_t start_time;
uint32_t post_positioning_start_time;
} module_status_t;

20
python/display_test.py Normal file
View File

@ -0,0 +1,20 @@
import time
from pyfis.xatlabs import xatLabsSplitFlapController
def main():
ctrl = xatLabsSplitFlapController("COM5", debug=True)
time.sleep(2)
pos = 0
while True:
print(pos)
ctrl.set_positions_addressed({4: pos, 5: pos, 6: pos, 7: pos})
ctrl.update()
pos += 1
input("Enter")
if __name__ == "__main__":
main()