2020-08-16 16:40:05 +02:00
|
|
|
// Copyright 2020 Lukas Haubaum
|
|
|
|
//
|
|
|
|
// Licensed under the GNU Affero General Public License, Version 3;
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
|
|
|
|
// https://www.gnu.org/licenses/agpl-3.0.html
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
#include <string.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include "freertos/FreeRTOS.h"
|
|
|
|
#include "freertos/task.h"
|
|
|
|
#include "esp_log.h"
|
|
|
|
#include "driver/gpio.h"
|
|
|
|
|
2020-09-29 19:58:01 +02:00
|
|
|
#include "display.h"
|
|
|
|
#include "display-gfx.h"
|
2020-08-16 16:40:05 +02:00
|
|
|
|
|
|
|
#include "wifi-controller.h"
|
|
|
|
|
|
|
|
#include "interface.h"
|
|
|
|
|
|
|
|
static int interface_report_tan[10] = {5, 5, 5, 5, 5, 5, 5, 5, 5, 5};
|
|
|
|
static int interface_report_tan_index = 0;
|
|
|
|
|
|
|
|
void interface_report_set(void)
|
|
|
|
{
|
|
|
|
interface_main_start();
|
|
|
|
}
|
|
|
|
|
|
|
|
void interface_report_rst(void)
|
|
|
|
{
|
|
|
|
// TODO: REPORT here, check tan etc.
|
|
|
|
}
|
|
|
|
|
|
|
|
void interface_report_lft(void)
|
|
|
|
{
|
|
|
|
if (interface_report_tan_index > 0)
|
|
|
|
{
|
|
|
|
interface_report_tan_index--;
|
|
|
|
}
|
|
|
|
ESP_LOGD(INTERFACE_LOG, "tan index %d", interface_report_tan_index);
|
|
|
|
}
|
|
|
|
|
|
|
|
void interface_report_rht(void)
|
|
|
|
{
|
|
|
|
if (interface_report_tan_index < 9)
|
|
|
|
{
|
|
|
|
interface_report_tan_index++;
|
|
|
|
}
|
|
|
|
ESP_LOGD(INTERFACE_LOG, "tan index %d", interface_report_tan_index);
|
|
|
|
}
|
|
|
|
|
|
|
|
void interface_report_up(void)
|
|
|
|
{
|
|
|
|
if (interface_report_tan[interface_report_tan_index] > 0)
|
|
|
|
{
|
|
|
|
interface_report_tan[interface_report_tan_index]--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
interface_report_tan[interface_report_tan_index] = 9;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void interface_report_dwn(void)
|
|
|
|
{
|
|
|
|
if (interface_report_tan[interface_report_tan_index] < 9)
|
|
|
|
{
|
|
|
|
interface_report_tan[interface_report_tan_index]++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
interface_report_tan[interface_report_tan_index] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void interface_report_display(void)
|
|
|
|
{
|
2020-09-29 19:58:01 +02:00
|
|
|
display_menu_headline( interface_get_label_text(&interface_text_headline_tan), false, 0);
|
2020-08-16 16:40:05 +02:00
|
|
|
|
|
|
|
// buttons
|
2020-09-29 19:58:01 +02:00
|
|
|
display_set_button( interface_get_label_text(&interface_text_button_cancel), true, false);
|
|
|
|
display_set_button( interface_get_label_text(&interface_text_button_ok), false, true);
|
2020-08-16 16:40:05 +02:00
|
|
|
|
|
|
|
static char tan_buffer[10] = {0};
|
|
|
|
|
|
|
|
if (interface_report_tan_index > 0)
|
|
|
|
{
|
2020-09-29 19:58:01 +02:00
|
|
|
display_data( display_gfx_arrow_left, 8, 3, 8, false);
|
2020-08-16 16:40:05 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-09-29 19:58:01 +02:00
|
|
|
display_data( display_gfx_clear, 8, 3, 8, false);
|
2020-08-16 16:40:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (interface_report_tan_index < 9)
|
|
|
|
{
|
2020-09-29 19:58:01 +02:00
|
|
|
display_data( display_gfx_arrow_right, 8, 3, 112, false);
|
2020-08-16 16:40:05 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-09-29 19:58:01 +02:00
|
|
|
display_data( display_gfx_clear, 8, 3, 112, false);
|
2020-08-16 16:40:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < interface_report_tan_index + 1; i++)
|
|
|
|
{
|
|
|
|
sprintf(&tan_buffer[i], "%d", interface_report_tan[i]);
|
|
|
|
}
|
|
|
|
|
2020-09-29 19:58:01 +02:00
|
|
|
display_clear_line( 2, false);
|
|
|
|
display_clear_line( 4, false);
|
2020-08-16 16:40:05 +02:00
|
|
|
|
2020-09-29 19:58:01 +02:00
|
|
|
display_text_line_column( "-", 3, 5, false);
|
|
|
|
display_text_line_column( "-", 3, 9, false);
|
|
|
|
display_text_line_column( "___", 3, 2, false);
|
|
|
|
display_text_line_column( "___", 3, 6, false);
|
|
|
|
display_text_line_column( "____", 3, 10, false);
|
2020-08-16 16:40:05 +02:00
|
|
|
|
|
|
|
int offset = 2;
|
|
|
|
for (int i = 0; i < 3; i++)
|
|
|
|
{
|
|
|
|
if (i < interface_report_tan_index)
|
|
|
|
{
|
2020-09-29 19:58:01 +02:00
|
|
|
display_chars( &tan_buffer[i], 1, 3, i + offset, true);
|
2020-08-16 16:40:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (interface_report_tan_index > 2)
|
|
|
|
{
|
|
|
|
offset = 3;
|
|
|
|
for (int i = 3; i < 6; i++)
|
|
|
|
{
|
|
|
|
if (i < interface_report_tan_index)
|
|
|
|
{
|
2020-09-29 19:58:01 +02:00
|
|
|
display_chars( &tan_buffer[i], 1, 3, i + offset, true);
|
2020-08-16 16:40:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (interface_report_tan_index > 5)
|
|
|
|
{
|
|
|
|
offset = 4;
|
|
|
|
for (int i = 6; i < 10; i++)
|
|
|
|
{
|
|
|
|
if (i < interface_report_tan_index)
|
|
|
|
{
|
2020-09-29 19:58:01 +02:00
|
|
|
display_chars( &tan_buffer[i], 1, 3, i + offset, true);
|
2020-08-16 16:40:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-29 19:58:01 +02:00
|
|
|
display_data( display_gfx_arrow_up, 8, 2, interface_report_tan_index * 8 + offset * 8, false);
|
|
|
|
display_data( display_gfx_arrow_down, 8, 4, interface_report_tan_index * 8 + offset * 8, false);
|
2020-08-16 16:40:05 +02:00
|
|
|
|
2020-09-29 19:58:01 +02:00
|
|
|
display_chars( &tan_buffer[interface_report_tan_index], 1, 3, interface_report_tan_index + offset, false);
|
2020-08-16 16:40:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void interface_report_start(void)
|
|
|
|
{
|
2020-09-29 19:58:01 +02:00
|
|
|
interface_register_command_callback(INTERFACE_COMMAND_RST, &interface_report_rst);
|
|
|
|
interface_register_command_callback(INTERFACE_COMMAND_SET, &interface_report_set);
|
|
|
|
interface_register_command_callback(INTERFACE_COMMAND_LFT, &interface_report_lft);
|
|
|
|
interface_register_command_callback(INTERFACE_COMMAND_RHT, &interface_report_rht);
|
|
|
|
interface_register_command_callback(INTERFACE_COMMAND_UP, &interface_report_up);
|
|
|
|
interface_register_command_callback(INTERFACE_COMMAND_DWN, &interface_report_dwn);
|
|
|
|
interface_register_command_callback(INTERFACE_COMMAND_MID, NULL);
|
2020-08-16 16:40:05 +02:00
|
|
|
interface_set_display_function(&interface_report_display);
|
|
|
|
|
|
|
|
ESP_LOGD(INTERFACE_LOG, "start report interface");
|
|
|
|
}
|