Исправления мелких багов
This commit is contained in:
66
emulator.cpp
66
emulator.cpp
@@ -145,22 +145,13 @@ static void image_draw_borders() {
|
||||
image_insert_sprite(0, (int)(COLS - strlen(tmp) - 2), tmp, false);
|
||||
}
|
||||
|
||||
static void showAll() {
|
||||
// 10 строк, 10*(\sb%1d\s) = 40
|
||||
// барабан хочу показывать так
|
||||
//
|
||||
// # Bx | Bx | Bx
|
||||
// #time|time|time
|
||||
//
|
||||
|
||||
image_init();
|
||||
image_draw_borders();
|
||||
char tmp[64];
|
||||
sprintf(tmp, "Lock1=%2d Lock2=%2d", robot1_lock_zone, robot2_lock_zone);
|
||||
image_insert_sprite(0, 2, tmp);
|
||||
static int barrels_count = 0, barrels_time = 0, max_time = 0;
|
||||
|
||||
static void collectBarrelsStatistic() {
|
||||
barrels_time = 0;
|
||||
barrels_count = 0;
|
||||
|
||||
int barrels_count = 0, barrels_time = 0;
|
||||
static int max_time = 0;
|
||||
for (int i = 0; i < BARRELS_COUNT; i++) {
|
||||
if (barrels[i].flags.is_exist) {
|
||||
barrels_count++;
|
||||
@@ -177,7 +168,23 @@ static void showAll() {
|
||||
if (max_time < barrels_time) {
|
||||
max_time = barrels_time;
|
||||
}
|
||||
}
|
||||
|
||||
static void showAll() {
|
||||
// 10 строк, 10*(\sb%1d\s) = 40
|
||||
// барабан хочу показывать так
|
||||
//
|
||||
// # Bx | Bx | Bx
|
||||
// #time|time|time
|
||||
//
|
||||
|
||||
image_init();
|
||||
image_draw_borders();
|
||||
char tmp[64];
|
||||
sprintf(tmp, "Lock1=%2d Lock2=%2d", robot1_lock_zone, robot2_lock_zone);
|
||||
image_insert_sprite(0, 2, tmp);
|
||||
|
||||
collectBarrelsStatistic();
|
||||
sprintf(tmp, "barrels=%2d time=%d max_time=%d", barrels_count, barrels_time, max_time);
|
||||
image_insert_sprite(0, 25, tmp);
|
||||
|
||||
@@ -188,11 +195,24 @@ static void showAll() {
|
||||
for (int i = 0; i < BARRELS_COUNT; i++) {
|
||||
const auto& b = barrels[i];
|
||||
if (b.flags.is_exist) {
|
||||
char flag_r = ' ';
|
||||
if (b.flags.is_night) {
|
||||
flag_r = 'n';
|
||||
}
|
||||
if (b.flags.is_empty) {
|
||||
flag_r = 'e';
|
||||
}
|
||||
|
||||
char flag_l = ' ';
|
||||
if (b.flags.robot) {
|
||||
flag_l = '*';
|
||||
}
|
||||
|
||||
if (b.flags.is_up) {
|
||||
sprintf(tmp, " B%d", i);
|
||||
sprintf(tmp, "%cB%d%c", flag_l, i, flag_r);
|
||||
image_insert_sprite(4, (b.zone * 5) + 1, tmp);
|
||||
} else {
|
||||
sprintf(tmp, " B%d\n%04d", i, b.software_timer);
|
||||
sprintf(tmp, "%cB%d%c\n%04d", flag_l, i, flag_r, b.software_timer);
|
||||
image_insert_sprite(5, (b.zone * 5) + 1, tmp);
|
||||
}
|
||||
|
||||
@@ -202,15 +222,15 @@ static void showAll() {
|
||||
// рисуем роботов
|
||||
if (hla_robot1_en) {
|
||||
sprintf(tmp, "R1");
|
||||
image_insert_sprite(2 + (robot1.mz.is_up ? 0 : 2),
|
||||
(robot1.dx.current_zone * 5) + 2 + (robot1_offset_pos * 2),
|
||||
image_insert_sprite(2 + (robot1.mz.is_up ? 0 : 2) - (robot1.mx.correct_sensor ? 1 : 0),
|
||||
(robot1.dx.current_zone * 5) + 2 + (robot1_offset_pos * 2) + (robot1.mx.correct_sensor ? 1 : 0),
|
||||
tmp);
|
||||
}
|
||||
|
||||
if (hla_robot2_en) {
|
||||
sprintf(tmp, "R2");
|
||||
image_insert_sprite(2 + (robot2.mz.is_up ? 0 : 2),
|
||||
(robot2.dx.current_zone * 5) + 2 + (robot2_offset_pos * 2),
|
||||
(robot2.dx.current_zone * 5) + 2 + (robot2_offset_pos * 2) - (robot2.mx.correct_sensor ? 1 : 0),
|
||||
tmp);
|
||||
}
|
||||
|
||||
@@ -262,7 +282,13 @@ int main() {
|
||||
while (true) {
|
||||
_scheduler_software_timer = 1;
|
||||
|
||||
button_load = 1;
|
||||
// подсчитаем статистику
|
||||
collectBarrelsStatistic();
|
||||
|
||||
// грузим не больше 5 барабанов
|
||||
if (barrels_count < 5) {
|
||||
button_load = 1;
|
||||
}
|
||||
|
||||
robot_main();
|
||||
scheduler_main();
|
||||
|
||||
Reference in New Issue
Block a user