code
stringlengths
1
1.05M
repo_name
stringlengths
6
83
path
stringlengths
3
242
language
stringclasses
222 values
license
stringclasses
20 values
size
int64
1
1.05M
#include <stdio.h> #include <stdlib.h> #include <string.h> #if MICROPY_PY_BLE #include "modble.h" #include "py/builtin.h" #include "py/mperrno.h" #include "py/obj.h" #include "py/runtime.h" #include "py/stackctrl.h" #include "ulog/ulog.h" #define LOG_TAG "ble" STATIC mp_obj_t cb_ble_event[BLE_EVENT_MAX] = { 0 }; void native_bt_host_gatts_handle_write(uint8_t *data, size_t len) { mp_obj_t cb_chara_written = cb_ble_event[BLE_EVENT_CHARA_WRITTEN]; mp_sched_carg_t *carg = make_cargs(MP_SCHED_CTYPE_SINGLE); make_carg_entry(carg, 0, MP_SCHED_ENTRY_TYPE_BYTES, len, data, NULL); callback_to_python_LoBo(cb_chara_written, mp_const_none, carg); } void py_ble_event_notify(int16_t handle, int32_t state) { mp_obj_t cb_net_status = cb_ble_event[BLE_EVENT_NET_STATUS]; mp_sched_carg_t *carg = make_cargs(MP_SCHED_CTYPE_DICT); make_carg_entry(carg, 0, MP_SCHED_ENTRY_TYPE_INT, handle, NULL, NULL); make_carg_entry(carg, 1, MP_SCHED_ENTRY_TYPE_INT, state, NULL, NULL); callback_to_python_LoBo(cb_net_status, mp_const_none, carg); } /**************************************************/ /************* For ble host operation *************/ /**************************************************/ STATIC mp_obj_t ble_open(mp_obj_t device_name_in, mp_obj_t conn_num_max_in) { amp_bt_host_adapter_init_t init = { 0 }; init.dev_name = mp_obj_str_get_str(device_name_in); init.conn_num_max = mp_obj_get_int(conn_num_max_in); mp_int_t ret = py_bt_host_adapter_init(&init); return MP_OBJ_NEW_SMALL_INT(ret); } MP_DEFINE_CONST_FUN_OBJ_2(ble_open_obj, ble_open); STATIC mp_obj_t ble_startAdv(mp_obj_t *data) { if (!mp_obj_is_dict_or_ordereddict(data)) { LOGE(LOG_TAG, "%s param type must be dict \r\n", __func__); return mp_obj_new_int(MP_EINVAL); } amp_bt_host_adapter_adv_start_t adv_param = { 0 }; mp_obj_t index = mp_obj_new_str_via_qstr("type", strlen("type")); mp_obj_t value = mp_obj_dict_get(data, index); if (mp_obj_is_int(value)) { adv_param.type = mp_obj_get_int(value); } else { LOGE(LOG_TAG, "%s key type value must be int \r\n", __func__); return mp_obj_new_int(MP_EINVAL); } index = mp_obj_new_str_via_qstr("adv_data", strlen("adv_data")); value = mp_obj_dict_get(data, index); if (mp_obj_is_str(value)) { adv_param.adv_data = mp_obj_str_get_str(value); } else { LOGE(LOG_TAG, "%s key adv_data value must be str \r\n", __func__); return mp_obj_new_int(MP_EINVAL); } index = mp_obj_new_str_via_qstr("scan_rsp_data", strlen("scan_rsp_data")); value = mp_obj_dict_get(data, index); if (mp_obj_is_str(value)) { adv_param.scan_rsp_data = mp_obj_str_get_str(value); } else { LOGE(LOG_TAG, "%s key scan_rsp_data value must be str \r\n", __func__); return mp_obj_new_int(MP_EINVAL); } index = mp_obj_new_str_via_qstr("interval_min", strlen("interval_min")); value = mp_obj_dict_get(data, index); if (mp_obj_is_int(value)) { adv_param.interval_min = mp_obj_get_int(value); } else { LOGE(LOG_TAG, "%s key interval_min value must be int \r\n", __func__); return mp_obj_new_int(MP_EINVAL); } index = mp_obj_new_str_via_qstr("interval_max", strlen("interval_max")); value = mp_obj_dict_get(data, index); if (mp_obj_is_int(value)) { adv_param.interval_max = mp_obj_get_int(value); } else { LOGE(LOG_TAG, "%s key interval_max value must be int \r\n", __func__); return mp_obj_new_int(MP_EINVAL); } index = mp_obj_new_str_via_qstr("channel_map", strlen("channel_map")); value = mp_obj_dict_get(data, index); if (mp_obj_is_int(value)) { adv_param.channel_map = mp_obj_get_int(value); } else { LOGE(LOG_TAG, "%s key channel_map value must be int \r\n", __func__); return mp_obj_new_int(MP_EINVAL); } mp_int_t ret = bt_host_adapter_start_adv(&adv_param); return MP_OBJ_NEW_SMALL_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(ble_startAdv_obj, ble_startAdv); STATIC mp_obj_t ble_stopAdv(void) { mp_int_t ret = ble_stack_adv_stop(); return MP_OBJ_NEW_SMALL_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_0(ble_stopAdv_obj, ble_stopAdv); STATIC mp_obj_t ble_addService(mp_obj_t srv_in) { mp_int_t ret = -1; amp_bt_host_adapter_gatts_srvc_t service = { 0 }; mp_obj_t s_uuid_obj = mp_obj_dict_get(srv_in, mp_obj_new_strn("uuid")); service.s_uuid = mp_obj_str_get_str(s_uuid_obj); service.attr_cnt += 1; mp_obj_t chara_list_obj = mp_obj_dict_get(srv_in, mp_obj_new_strn("charas")); size_t chara_num; mp_obj_t *chara_items = NULL; mp_obj_list_get(chara_list_obj, &chara_num, &chara_items); /* if we have service to add */ if (chara_num != 0) { amp_bt_host_adapter_gatt_chars_t *chara_list = m_new0(amp_bt_host_adapter_gatt_chars_t, chara_num); if (chara_list == NULL) { mp_raise_OSError(MP_ENOMEM); return mp_const_none; } else { service.chars = chara_list; } /* parser chara_list */ for (size_t i = 0; i < chara_num; i++) { /* parser each chara item */ size_t chara_items_num = 0; mp_obj_t *chara_items_eles = NULL; mp_obj_list_get(chara_items[i], &chara_items_num, &chara_items_eles); bool has_descr = false; if (chara_items_num != 0) { chara_list->char_uuid = mp_obj_str_get_str(chara_items_eles[0]); chara_list->permission = mp_obj_str_get_str(chara_items_eles[1]); if (mp_obj_is_str(chara_items_eles[2])) { chara_list->descr_uuid = mp_obj_str_get_str(chara_items_eles[2]); has_descr = true; } else { chara_list->descr_uuid = NULL; } if (mp_obj_is_str(chara_items_eles[3])) { chara_list->descr_type = mp_obj_str_get_str(chara_items_eles[3]); has_descr = true; } else { chara_list->descr_type = NULL; } if (has_descr == true) { service.attr_cnt += 3; } else { service.attr_cnt += 2; } chara_list += 1; } else { mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("Charas Null")); } } ret = bt_gatts_adapter_add_service(&service); m_del(amp_bt_host_adapter_gatt_chars_t, service.chars, chara_num); } return MP_OBJ_NEW_SMALL_INT(ret); } MP_DEFINE_CONST_FUN_OBJ_1(ble_addService_obj, ble_addService); STATIC mp_obj_t ble_updateCharacter(mp_obj_t uuid_in, mp_obj_t data_in) { const char *uuid = mp_obj_str_get_str(uuid_in); mp_buffer_info_t data; mp_get_buffer_raise(data_in, &data, MP_BUFFER_READ); mp_int_t ret = bt_gatts_adapter_update_chars(uuid, data.buf, data.len); return MP_OBJ_NEW_SMALL_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_2(ble_updateCharacter_obj, ble_updateCharacter); STATIC mp_obj_t ble_on(mp_obj_t event_in, mp_obj_t cb) { mp_int_t event = mp_obj_get_int(event_in); if (event >= BLE_EVENT_MAX) { return mp_obj_new_int(MP_EINVAL); } cb_ble_event[event] = cb; return mp_obj_new_int(0); } STATIC MP_DEFINE_CONST_FUN_OBJ_2(ble_on_obj, ble_on); STATIC const mp_rom_map_elem_t ble_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ble) }, { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&ble_open_obj) }, { MP_ROM_QSTR(MP_QSTR_startAdv), MP_ROM_PTR(&ble_startAdv_obj) }, { MP_ROM_QSTR(MP_QSTR_stopAdv), MP_ROM_PTR(&ble_stopAdv_obj) }, { MP_ROM_QSTR(MP_QSTR_addService), MP_ROM_PTR(&ble_addService_obj) }, { MP_ROM_QSTR(MP_QSTR_updateCharacter), MP_ROM_PTR(&ble_updateCharacter_obj) }, { MP_ROM_QSTR(MP_QSTR_on), MP_ROM_PTR(&ble_on_obj) }, { MP_ROM_QSTR(MP_QSTR_STATUS), MP_ROM_INT(BLE_EVENT_NET_STATUS) }, { MP_ROM_QSTR(MP_QSTR_CHARAWRITE), MP_ROM_INT(BLE_EVENT_CHARA_WRITTEN) }, }; STATIC MP_DEFINE_CONST_DICT(ble_module_globals, ble_module_globals_table); const mp_obj_module_t mp_module_ble = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&ble_module_globals, }; MP_REGISTER_MODULE(MP_QSTR_ble, mp_module_ble, MICROPY_PY_BLE); #endif
YifuLiu/AliOS-Things
components/py_engine/modules/ble/modble.c
C
apache-2.0
8,477
#ifndef _PY_MODBLE_H_ #define _PY_MODBLE_H_ #include "aos/ble.h" enum ble_event { BLE_EVENT_NET_STATUS = 0, BLE_EVENT_CHARA_WRITTEN, BLE_EVENT_MAX }; typedef struct { char *dev_name; uint16_t conn_num_max; } amp_bt_host_adapter_init_t; typedef struct { int32_t type; char *adv_data; char *scan_rsp_data; int32_t interval_min; int32_t interval_max; int32_t channel_map; } amp_bt_host_adapter_adv_start_t; typedef struct { int32_t type; uint16_t interval; uint16_t window; } amp_bt_host_adapter_scan_start_t; typedef struct { const char *char_uuid; const char *permission; const char *descr_uuid; const char *descr_type; } amp_bt_host_adapter_gatt_chars_t; typedef struct { char *s_uuid; uint32_t attr_cnt; amp_bt_host_adapter_gatt_chars_t *chars; } amp_bt_host_adapter_gatts_srvc_t; typedef struct { size_t len; uint8_t *data; } amp_bt_gatts_adapter_usr_data_t; // GAP int py_bt_host_adapter_init(amp_bt_host_adapter_init_t *init); int bt_host_adapter_start_adv(amp_bt_host_adapter_adv_start_t *adv_param); int bt_host_adapter_stop_adv(void); // GATTS void native_bt_host_gatts_handle_write(uint8_t data[], size_t len); int bt_gatts_adapter_add_service(amp_bt_host_adapter_gatts_srvc_t *srvc); int bt_gatts_adapter_update_chars(char *uuid, uint8_t *data, size_t len); #endif
YifuLiu/AliOS-Things
components/py_engine/modules/ble/modble.h
C
apache-2.0
1,377
/** * @file lv_conf.h * Configuration file for v8.1.0-release */ /* * Copy this file as `lv_conf.h` * 1. simply next to the `lvgl` folder * 2. or any other places and * - define `LV_CONF_INCLUDE_SIMPLE` * - add the path as include path */ /* clang-format off */ #if 1 /*Set it to "1" to enable content*/ #ifndef LV_CONF_H #define LV_CONF_H #include <stdint.h> #define LV_USE_FREETYPE 1 /*==================== COLOR SETTINGS *====================*/ /*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/ #ifndef LV_COLOR_DEPTH #define LV_COLOR_DEPTH 16 #endif /*Swap the 2 bytes of RGB565 color. Useful if the display has an 8-bit interface (e.g. SPI)*/ #ifndef LV_COLOR_16_SWAP #define LV_COLOR_16_SWAP 1 #endif /*Enable more complex drawing routines to manage screens transparency. *Can be used if the UI is above another layer, e.g. an OSD menu or video player. *Requires `LV_COLOR_DEPTH = 32` colors and the screen's `bg_opa` should be set to non LV_OPA_COVER value*/ #define LV_COLOR_SCREEN_TRANSP 0 /* Adjust color mix functions rounding. GPUs might calculate color mix (blending) differently. * 0: round down, 64: round up from x.75, 128: round up from half, 192: round up from x.25, 254: round up */ #define LV_COLOR_MIX_ROUND_OFS (LV_COLOR_DEPTH == 32 ? 0: 128) /*Images pixels with this color will not be drawn if they are chroma keyed)*/ #define LV_COLOR_CHROMA_KEY lv_color_hex(0x00ff00) /*pure green*/ /*========================= MEMORY SETTINGS *=========================*/ /*1: use custom malloc/free, 0: use the built-in `lv_mem_alloc()` and `lv_mem_free()`*/ #define LV_MEM_CUSTOM 1 #if LV_MEM_CUSTOM == 0 /*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/ # define LV_MEM_SIZE (32U * 1024U) /*[bytes]*/ /*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/ # define LV_MEM_ADR 0 /*0: unused*/ /*Instead of an address give a memory allocator that will be called to get a memory pool for LVGL. E.g. my_malloc*/ #if LV_MEM_ADR == 0 //#define LV_MEM_POOL_INCLUDE your_alloc_library /* Uncomment if using an external allocator*/ //#define LV_MEM_POOL_ALLOC your_alloc /* Uncomment if using an external allocator*/ #endif #else /*LV_MEM_CUSTOM*/ # define LV_MEM_CUSTOM_INCLUDE "include/lv_mp_mem_custom_include.h" /*Header for the dynamic memory function*/ # define LV_MEM_CUSTOM_ALLOC m_malloc /*Wrapper to malloc*/ # define LV_MEM_CUSTOM_FREE m_free /*Wrapper to free*/ # define LV_MEM_CUSTOM_REALLOC m_realloc #endif /*LV_MEM_CUSTOM*/ /*Use the standard `memcpy` and `memset` instead of LVGL's own functions. (Might or might not be faster).*/ #define LV_MEMCPY_MEMSET_STD 0 /*==================== HAL SETTINGS *====================*/ /*Default display refresh period. LVG will redraw changed areas with this period time*/ #define LV_DISP_DEF_REFR_PERIOD 20 /*[ms]*/ /*Input device read period in milliseconds*/ #define LV_INDEV_DEF_READ_PERIOD 30 /*[ms]*/ /*Use a custom tick source that tells the elapsed time in milliseconds. *It removes the need to manually update the tick with `lv_tick_inc()`)*/ #define LV_TICK_CUSTOM 0 #if LV_TICK_CUSTOM #define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the system time function*/ #define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current system time in ms*/ #endif /*LV_TICK_CUSTOM*/ /*Default Dot Per Inch. Used to initialize default sizes such as widgets sized, style paddings. *(Not so important, you can adjust it to modify default sizes and spaces)*/ #define LV_DPI_DEF 130 /*[px/inch]*/ /*======================= * FEATURE CONFIGURATION *=======================*/ /*------------- * Drawing *-----------*/ /*Enable complex draw engine. *Required to draw shadow, gradient, rounded corners, circles, arc, skew lines, image transformations or any masks*/ #define LV_DRAW_COMPLEX 1 #if LV_DRAW_COMPLEX != 0 /*Allow buffering some shadow calculation. *LV_SHADOW_CACHE_SIZE is the max. shadow size to buffer, where shadow size is `shadow_width + radius` *Caching has LV_SHADOW_CACHE_SIZE^2 RAM cost*/ #define LV_SHADOW_CACHE_SIZE 0 /* Set number of maximally cached circle data. * The circumference of 1/4 circle are saved for anti-aliasing * radius * 4 bytes are used per circle (the most often used radiuses are saved) * 0: to disable caching */ #define LV_CIRCLE_CACHE_SIZE 4 #endif /*LV_DRAW_COMPLEX*/ /*Default image cache size. Image caching keeps the images opened. *If only the built-in image formats are used there is no real advantage of caching. (I.e. if no new image decoder is added) *With complex image decoders (e.g. PNG or JPG) caching can save the continuous open/decode of images. *However the opened images might consume additional RAM. *0: to disable caching*/ #define LV_IMG_CACHE_DEF_SIZE 64 /*Maximum buffer size to allocate for rotation. Only used if software rotation is enabled in the display driver.*/ #define LV_DISP_ROT_MAX_BUF (10*1024) /*------------- * GPU *-----------*/ /*Use STM32's DMA2D (aka Chrom Art) GPU*/ #define LV_USE_GPU_STM32_DMA2D 0 #if LV_USE_GPU_STM32_DMA2D /*Must be defined to include path of CMSIS header of target processor e.g. "stm32f769xx.h" or "stm32f429xx.h"*/ #define LV_GPU_DMA2D_CMSIS_INCLUDE #endif /*Use NXP's PXP GPU iMX RTxxx platforms*/ #define LV_USE_GPU_NXP_PXP 0 #if LV_USE_GPU_NXP_PXP /*1: Add default bare metal and FreeRTOS interrupt handling routines for PXP (lv_gpu_nxp_pxp_osa.c) * and call lv_gpu_nxp_pxp_init() automatically during lv_init(). Note that symbol SDK_OS_FREE_RTOS * has to be defined in order to use FreeRTOS OSA, otherwise bare-metal implementation is selected. *0: lv_gpu_nxp_pxp_init() has to be called manually before lv_init() */ #define LV_USE_GPU_NXP_PXP_AUTO_INIT 0 #endif /*Use NXP's VG-Lite GPU iMX RTxxx platforms*/ #define LV_USE_GPU_NXP_VG_LITE 0 /*Use SDL renderer API*/ #ifndef LV_USE_GPU_SDL # ifdef CONFIG_LV_USE_GPU_SDL # define LV_USE_GPU_SDL CONFIG_LV_USE_GPU_SDL # else # define LV_USE_GPU_SDL 0 # endif #endif #if LV_USE_GPU_SDL # define LV_USE_EXTERNAL_RENDERER 1 # ifndef LV_GPU_SDL_INCLUDE # define LV_GPU_SDL_INCLUDE_PATH <SDL2/SDL.h> # endif #endif #ifndef LV_USE_EXTERNAL_RENDERER # define LV_USE_EXTERNAL_RENDERER 0 #endif /*------------- * Logging *-----------*/ /*Enable the log module*/ #define LV_USE_LOG 1 #if LV_USE_LOG /*How important log should be added: *LV_LOG_LEVEL_TRACE A lot of logs to give detailed information *LV_LOG_LEVEL_INFO Log important events *LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't cause a problem *LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail *LV_LOG_LEVEL_USER Only logs added by the user *LV_LOG_LEVEL_NONE Do not log anything*/ # define LV_LOG_LEVEL LV_LOG_LEVEL_WARN /*1: Print the log with 'printf'; *0: User need to register a callback with `lv_log_register_print_cb()`*/ # define LV_LOG_PRINTF 0 /*Enable/disable LV_LOG_TRACE in modules that produces a huge number of logs*/ # define LV_LOG_TRACE_MEM 1 # define LV_LOG_TRACE_TIMER 1 # define LV_LOG_TRACE_INDEV 1 # define LV_LOG_TRACE_DISP_REFR 1 # define LV_LOG_TRACE_EVENT 1 # define LV_LOG_TRACE_OBJ_CREATE 1 # define LV_LOG_TRACE_LAYOUT 1 # define LV_LOG_TRACE_ANIM 1 #endif /*LV_USE_LOG*/ /*------------- * Asserts *-----------*/ /*Enable asserts if an operation is failed or an invalid data is found. *If LV_USE_LOG is enabled an error message will be printed on failure*/ #define LV_USE_ASSERT_NULL 1 /*Check if the parameter is NULL. (Very fast, recommended)*/ #define LV_USE_ASSERT_MALLOC 1 /*Checks is the memory is successfully allocated or no. (Very fast, recommended)*/ #define LV_USE_ASSERT_STYLE 0 /*Check if the styles are properly initialized. (Very fast, recommended)*/ #define LV_USE_ASSERT_MEM_INTEGRITY 0 /*Check the integrity of `lv_mem` after critical operations. (Slow)*/ #define LV_USE_ASSERT_OBJ 0 /*Check the object's type and existence (e.g. not deleted). (Slow)*/ /*Add a custom handler when assert happens e.g. to restart the MCU*/ #define LV_ASSERT_HANDLER_INCLUDE <stdint.h> #define LV_ASSERT_HANDLER while(1); /*Halt by default*/ /*------------- * Others *-----------*/ /*1: Show CPU usage and FPS count in the right bottom corner*/ #define LV_USE_PERF_MONITOR 0 /*1: Show the used memory and the memory fragmentation in the left bottom corner * Requires LV_MEM_CUSTOM = 0*/ #define LV_USE_MEM_MONITOR 0 /*1: Draw random colored rectangles over the redrawn areas*/ #define LV_USE_REFR_DEBUG 0 /*Change the built in (v)snprintf functions*/ #define LV_SPRINTF_CUSTOM 1 #if LV_SPRINTF_CUSTOM # define LV_SPRINTF_INCLUDE <stdio.h> # define lv_snprintf snprintf # define lv_vsnprintf vsnprintf #else /*LV_SPRINTF_CUSTOM*/ # define LV_SPRINTF_USE_FLOAT 0 #endif /*LV_SPRINTF_CUSTOM*/ #define LV_USE_USER_DATA 1 /*Garbage Collector settings *Used if lvgl is bound to higher level language and the memory is managed by that language*/ #define LV_ENABLE_GC 1 /* Enable GC for Micropython */ #if LV_ENABLE_GC != 0 # define LV_GC_INCLUDE "py/mpstate.h" # define LV_MEM_CUSTOM_GET_SIZE gc_nbytes /*Wrapper to lv_mem_get_size*/ # define LV_GC_ROOT(x) MP_STATE_PORT(x) #endif /*LV_ENABLE_GC*/ /*1: Enable API to take snapshot for object*/ #define LV_USE_SNAPSHOT 1 /*===================== * COMPILER SETTINGS *====================*/ /*For big endian systems set to 1*/ #define LV_BIG_ENDIAN_SYSTEM 0 /*Define a custom attribute to `lv_tick_inc` function*/ #define LV_ATTRIBUTE_TICK_INC /*Define a custom attribute to `lv_timer_handler` function*/ #define LV_ATTRIBUTE_TIMER_HANDLER /*Define a custom attribute to `lv_disp_flush_ready` function*/ #define LV_ATTRIBUTE_FLUSH_READY /*Required alignment size for buffers*/ #define LV_ATTRIBUTE_MEM_ALIGN_SIZE /*Will be added where memories needs to be aligned (with -Os data might not be aligned to boundary by default). * E.g. __attribute__((aligned(4)))*/ #define LV_ATTRIBUTE_MEM_ALIGN /*Attribute to mark large constant arrays for example font's bitmaps*/ #define LV_ATTRIBUTE_LARGE_CONST /*Complier prefix for a big array declaration in RAM*/ #define LV_ATTRIBUTE_LARGE_RAM_ARRAY /*Place performance critical functions into a faster memory (e.g RAM)*/ #define LV_ATTRIBUTE_FAST_MEM /*Prefix variables that are used in GPU accelerated operations, often these need to be placed in RAM sections that are DMA accessible*/ #define LV_ATTRIBUTE_DMA /*Export integer constant to binding. This macro is used with constants in the form of LV_<CONST> that *should also appear on LVGL binding API such as Micropython.*/ #define LV_EXPORT_CONST_INT(int_value) enum {ENUM_##int_value = int_value} /*Extend the default -32k..32k coordinate range to -4M..4M by using int32_t for coordinates instead of int16_t*/ #define LV_USE_LARGE_COORD 0 /*================== * FONT USAGE *===================*/ /*Montserrat fonts with ASCII range and some symbols using bpp = 4 *https://fonts.google.com/specimen/Montserrat*/ #define LV_FONT_MONTSERRAT_8 1 #define LV_FONT_MONTSERRAT_10 1 #define LV_FONT_MONTSERRAT_12 1 #define LV_FONT_MONTSERRAT_14 1 #define LV_FONT_MONTSERRAT_16 1 #define LV_FONT_MONTSERRAT_18 1 #define LV_FONT_MONTSERRAT_20 1 #define LV_FONT_MONTSERRAT_22 1 #define LV_FONT_MONTSERRAT_24 1 #define LV_FONT_MONTSERRAT_26 1 #define LV_FONT_MONTSERRAT_28 1 #define LV_FONT_MONTSERRAT_30 1 #define LV_FONT_MONTSERRAT_32 1 #define LV_FONT_MONTSERRAT_34 1 #define LV_FONT_MONTSERRAT_36 1 #define LV_FONT_MONTSERRAT_38 1 #define LV_FONT_MONTSERRAT_40 1 #define LV_FONT_MONTSERRAT_42 1 #define LV_FONT_MONTSERRAT_44 1 #define LV_FONT_MONTSERRAT_46 1 #define LV_FONT_MONTSERRAT_48 1 /*Demonstrate special features*/ #define LV_FONT_MONTSERRAT_12_SUBPX 0 #define LV_FONT_MONTSERRAT_28_COMPRESSED 0 /*bpp = 3*/ #define LV_FONT_DEJAVU_16_PERSIAN_HEBREW 1 /*Hebrew, Arabic, Perisan letters and all their forms*/ #define LV_FONT_SIMSUN_16_CJK 0 /*1000 most common CJK radicals*/ /*Pixel perfect monospace fonts*/ #define LV_FONT_UNSCII_8 0 #define LV_FONT_UNSCII_16 0 /*Optionally declare custom fonts here. *You can use these fonts as default font too and they will be available globally. *E.g. #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) LV_FONT_DECLARE(my_font_2)*/ #define LV_FONT_CUSTOM_DECLARE /*Always set a default font*/ #define LV_FONT_DEFAULT &lv_font_montserrat_14 /*Enable handling large font and/or fonts with a lot of characters. *The limit depends on the font size, font face and bpp. *Compiler error will be triggered if a font needs it.*/ #define LV_FONT_FMT_TXT_LARGE 0 /*Enables/disables support for compressed fonts.*/ #define LV_USE_FONT_COMPRESSED 0 /*Enable subpixel rendering*/ #define LV_USE_FONT_SUBPX 0 #if LV_USE_FONT_SUBPX /*Set the pixel order of the display. Physical order of RGB channels. Doesn't matter with "normal" fonts.*/ #define LV_FONT_SUBPX_BGR 0 /*0: RGB; 1:BGR order*/ #endif /*================= * TEXT SETTINGS *=================*/ /** * Select a character encoding for strings. * Your IDE or editor should have the same character encoding * - LV_TXT_ENC_UTF8 * - LV_TXT_ENC_ASCII */ #define LV_TXT_ENC LV_TXT_ENC_UTF8 /*Can break (wrap) texts on these chars*/ #define LV_TXT_BREAK_CHARS " ,.;:-_" /*If a word is at least this long, will break wherever "prettiest" *To disable, set to a value <= 0*/ #define LV_TXT_LINE_BREAK_LONG_LEN 0 /*Minimum number of characters in a long word to put on a line before a break. *Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/ #define LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN 3 /*Minimum number of characters in a long word to put on a line after a break. *Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/ #define LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN 3 /*The control character to use for signalling text recoloring.*/ #define LV_TXT_COLOR_CMD "#" /*Support bidirectional texts. Allows mixing Left-to-Right and Right-to-Left texts. *The direction will be processed according to the Unicode Bidirectional Algorithm: *https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/ #define LV_USE_BIDI 1 #if LV_USE_BIDI /*Set the default direction. Supported values: *`LV_BASE_DIR_LTR` Left-to-Right *`LV_BASE_DIR_RTL` Right-to-Left *`LV_BASE_DIR_AUTO` detect texts base direction*/ #define LV_BIDI_BASE_DIR_DEF LV_BASE_DIR_AUTO #endif /*Enable Arabic/Persian processing *In these languages characters should be replaced with an other form based on their position in the text*/ #define LV_USE_ARABIC_PERSIAN_CHARS 1 /*================== * WIDGET USAGE *================*/ /*Documentation of the widgets: https://docs.lvgl.io/latest/en/html/widgets/index.html*/ #define LV_USE_ARC 1 #define LV_USE_ANIMIMG 1 #define LV_USE_BAR 1 #define LV_USE_BTN 1 #define LV_USE_BTNMATRIX 1 #define LV_USE_CANVAS 1 #define LV_USE_CHECKBOX 1 #define LV_USE_DROPDOWN 1 /*Requires: lv_label*/ #define LV_USE_IMG 1 /*Requires: lv_label*/ #define LV_USE_LABEL 1 #if LV_USE_LABEL # define LV_LABEL_TEXT_SELECTION 1 /*Enable selecting text of the label*/ # define LV_LABEL_LONG_TXT_HINT 1 /*Store some extra info in labels to speed up drawing of very long texts*/ #endif #define LV_USE_LINE 1 #define LV_USE_ROLLER 1 /*Requires: lv_label*/ #if LV_USE_ROLLER # define LV_ROLLER_INF_PAGES 7 /*Number of extra "pages" when the roller is infinite*/ #endif #define LV_USE_SLIDER 1 /*Requires: lv_bar*/ #define LV_USE_SWITCH 1 #define LV_USE_TEXTAREA 1 /*Requires: lv_label*/ #if LV_USE_TEXTAREA != 0 # define LV_TEXTAREA_DEF_PWD_SHOW_TIME 1500 /*ms*/ #endif #define LV_USE_TABLE 1 /*================== * EXTRA COMPONENTS *==================*/ /*----------- * Widgets *----------*/ #define LV_USE_CALENDAR 1 #if LV_USE_CALENDAR # define LV_CALENDAR_WEEK_STARTS_MONDAY 0 # if LV_CALENDAR_WEEK_STARTS_MONDAY # define LV_CALENDAR_DEFAULT_DAY_NAMES {"Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"} # else # define LV_CALENDAR_DEFAULT_DAY_NAMES {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"} # endif # define LV_CALENDAR_DEFAULT_MONTH_NAMES {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"} # define LV_USE_CALENDAR_HEADER_ARROW 1 # define LV_USE_CALENDAR_HEADER_DROPDOWN 1 #endif /*LV_USE_CALENDAR*/ #define LV_USE_CHART 1 #define LV_USE_COLORWHEEL 1 #define LV_USE_IMGBTN 1 #define LV_USE_KEYBOARD 1 #define LV_USE_LED 1 #define LV_USE_LIST 1 #define LV_USE_METER 1 #define LV_USE_MSGBOX 1 #define LV_USE_SPINBOX 1 #define LV_USE_SPINNER 1 #define LV_USE_TABVIEW 1 #define LV_USE_TILEVIEW 1 #define LV_USE_WIN 1 #define LV_USE_SPAN 1 #if LV_USE_SPAN /*A line text can contain maximum num of span descriptor */ # define LV_SPAN_SNIPPET_STACK_SIZE 64 #endif /*----------- * Themes *----------*/ /*A simple, impressive and very complete theme*/ #define LV_USE_THEME_DEFAULT 1 #if LV_USE_THEME_DEFAULT /*0: Light mode; 1: Dark mode*/ # define LV_THEME_DEFAULT_DARK 0 /*1: Enable grow on press*/ # define LV_THEME_DEFAULT_GROW 1 /*Default transition time in [ms]*/ # define LV_THEME_DEFAULT_TRANSITON_TIME 80 #endif /*LV_USE_THEME_DEFAULT*/ /*A very simple theme that is a good starting point for a custom theme*/ #define LV_USE_THEME_BASIC 1 /*A theme designed for monochrome displays*/ #define LV_USE_THEME_MONO 1 /*----------- * Layouts *----------*/ /*A layout similar to Flexbox in CSS.*/ #define LV_USE_FLEX 1 /*A layout similar to Grid in CSS.*/ #define LV_USE_GRID 1 #define LV_USE_FS_POSIX 'S' #define LV_USE_SJPG 1 #define LV_USE_PNG 1 /*================== * EXAMPLES *==================*/ /*Enable the examples to be built with the library*/ #define LV_BUILD_EXAMPLES 1 /*--END OF LV_CONF_H--*/ #endif /*LV_CONF_H*/ #endif /*End of "Content enable"*/
YifuLiu/AliOS-Things
components/py_engine/modules/display/esp32/lv_conf.h
C
apache-2.0
18,689
/* LVGL Example project * * Basic project to test LVGL on ESP32 based projects. * * This example code is in the Public Domain (or CC0 licensed, at your option.) * * Unless required by applicable law or agreed to in writing, this * software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. */ #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "axp192.h" #include "driver/gpio.h" #include "esp_log.h" #include "esp_system.h" #include "esp_task.h" #include "freertos/FreeRTOS.h" #include "freertos/semphr.h" #include "freertos/task.h" #include "lvgl_i2c/i2c_manager.h" #include "py/objstr.h" #include "py/runtime.h" #include "py/stackctrl.h" #if MICROPY_PY_THREAD #include "py/mpthread.h" #endif /* Littlevgl specific */ #ifdef LV_LVGL_H_INCLUDE_SIMPLE #include "lvgl.h" #else #include "lvgl/lvgl.h" #endif #include "lvgl_helpers.h" #include "moddisplay.h" #define TAG "disp_lvgl" #define LV_TICK_PERIOD_MS 1 #define I2C_0 i2c_hal(0) static bool lvgl_display_init = false; static void lv_tick_task(void *arg); static void guiTask(void *pvParameter); static void drawDisplay(); SemaphoreHandle_t xGuiSemaphore; typedef void (*mp_task_entry_t)(void *arg); struct mp_task_struct { mp_task_entry_t entry; size_t stack_size; void *arg; mp_obj_dict_t *dict_locals; mp_obj_dict_t *dict_globals; }; typedef struct _display_lvgl_obj_t { mp_obj_base_t base; } display_lvgl_obj_t; const mp_obj_type_t display_lvgl_type; void mp_thread_entry_c(void *arg) { struct mp_task_struct *task_struct = (struct mp_task_struct *)arg; mp_state_thread_t ts; mp_thread_set_state(&ts); mp_task_entry_t entry = task_struct->entry; void *task_param = task_struct->arg; mp_stack_set_top(&ts + 1); // need to include ts in root-pointer scan mp_stack_set_limit(task_struct->stack_size); #if MICROPY_ENABLE_PYSTACK // TODO threading and pystack is not fully supported, for now just make a small stack mp_obj_t mini_pystack[128]; mp_pystack_init(mini_pystack, &mini_pystack[128]); #endif ts.mp_pending_exception = MP_OBJ_NULL; // set locals and globals from the calling context mp_locals_set(task_struct->dict_locals); mp_globals_set(task_struct->dict_globals); // signal that we are set up and running entry(task_param); } int mp_thread_create_c(TaskFunction_t pxTaskCode, const char *const pcName, const uint32_t usStackDepth, void *const pvParameters, UBaseType_t uxPriority, TaskHandle_t *const pxCreatedTask, const BaseType_t xCoreID) { struct mp_task_struct *task_struct; task_struct = (struct mp_task_struct *)malloc(sizeof(struct mp_task_struct)); memset(task_struct, 0, sizeof(struct mp_task_struct)); task_struct->entry = pxTaskCode; task_struct->arg = pvParameters; task_struct->dict_locals = mp_locals_get(); task_struct->dict_globals = mp_globals_get(); task_struct->stack_size = usStackDepth - 1024; xTaskCreatePinnedToCore(mp_thread_entry_c, pcName, usStackDepth, task_struct, uxPriority, pxCreatedTask, xCoreID); return 0; } void start_display() { mp_thread_create_c(guiTask, "gui", 2 * 1024, NULL, ESP_TASK_PRIO_MIN + 1, NULL, 0); } void driver_init() { lvgl_driver_init(); start_display(); } STATIC mp_obj_t mp_lv_task_handler(mp_obj_t arg) { lv_task_handler(); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_lv_task_handler_obj, mp_lv_task_handler); static void guiTask(void *pvParameter) { (void)pvParameter; // ESP_LOGE(TAG, "gui task entern"); xGuiSemaphore = xSemaphoreCreateMutex(); /* Create and start a periodic timer interrupt to call lv_tick_inc */ const esp_timer_create_args_t periodic_timer_args = { .callback = &lv_tick_task, .name = "periodic_gui" }; esp_timer_handle_t periodic_timer; ESP_ERROR_CHECK(esp_timer_create(&periodic_timer_args, &periodic_timer)); ESP_ERROR_CHECK(esp_timer_start_periodic(periodic_timer, LV_TICK_PERIOD_MS * 1000)); while (1) { /* Delay 1 tick (assumes FreeRTOS tick is 10ms */ vTaskDelay(pdMS_TO_TICKS(30)); /* Try to take the semaphore, call lvgl related function on success */ if (pdTRUE == xSemaphoreTake(xGuiSemaphore, portMAX_DELAY)) { callback_to_python_LoBo((mp_obj_t)&mp_lv_task_handler_obj, mp_const_none, NULL); xSemaphoreGive(xGuiSemaphore); } } vTaskDelete(NULL); } /********************** * APPLICATION MAIN **********************/ STATIC mp_obj_t app_monkey_test(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { lv_monkey_init(); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mp_monkey_test, 0, app_monkey_test); static lv_disp_draw_buf_t disp_buf; static lv_disp_drv_t disp_drv; static lv_indev_drv_t indev_drv; static void drawDisplay() { // lv_color_t *buf1 = heap_caps_malloc(DISP_BUF_SIZE * sizeof(lv_color_t), MALLOC_CAP_DMA); lv_color_t *buf1 = (lv_color_t *)malloc(DISP_BUF_SIZE * sizeof(lv_color_t)); assert(buf1 != NULL); // lv_color_t *buf2 = heap_caps_malloc(DISP_BUF_SIZE * sizeof(lv_color_t), MALLOC_CAP_DMA); lv_color_t *buf2 = (lv_color_t *)malloc(DISP_BUF_SIZE * sizeof(lv_color_t)); assert(buf2 != NULL); uint32_t size_in_px = DISP_BUF_SIZE; lv_disp_draw_buf_init(&disp_buf, buf1, buf2, size_in_px); lv_disp_drv_init(&disp_drv); disp_drv.hor_res = 320; disp_drv.ver_res = 240; disp_drv.flush_cb = disp_driver_flush; disp_drv.draw_buf = &disp_buf; lv_disp_drv_register(&disp_drv); ESP_LOGE(TAG, "register touch driver"); lv_indev_drv_init(&indev_drv); indev_drv.read_cb = touch_driver_read; indev_drv.type = LV_INDEV_TYPE_POINTER; lv_indev_drv_register(&indev_drv); } static void lv_tick_task(void *arg) { (void)arg; lv_tick_inc(LV_TICK_PERIOD_MS); } static void display_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map) { // printf("display_flush area: %d %d %d %d\n", area->x1, area->y1, area->x2, area->y2); disp_driver_flush(drv, area, color_map); } DEFINE_PTR_OBJ(display_flush); static void touch_read(lv_indev_drv_t *drv, lv_indev_data_t *data) { // ESP_LOGE(TAG, "touch_read"); touch_driver_read(drv, data); } DEFINE_PTR_OBJ(touch_read); STATIC mp_obj_t is_initialized(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { bool _res = (bool)lvgl_display_init; printf("check init = %d;_res = %d;\r\n", lvgl_display_init, _res); return _res ? mp_const_true : mp_const_false; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mp_is_initialized_obj, 0, is_initialized); STATIC mp_obj_t app_init(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { ESP_LOGE(TAG, "app_init"); driver_init(); drawDisplay(); return mp_obj_new_int(0); } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mp_display_init_obj, 0, app_init); STATIC mp_obj_t app_draw(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { ESP_LOGE(TAG, "app_draw"); lv_init(); drawDisplay(); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mp_display_draw_obj, 0, app_draw); STATIC const mp_rom_map_elem_t display_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_lvgl_display) }, { MP_ROM_QSTR(MP_QSTR_is_initialized), MP_ROM_PTR(&mp_is_initialized_obj) }, { MP_ROM_QSTR(MP_QSTR_init), MP_ROM_PTR(&mp_display_init_obj) }, { MP_ROM_QSTR(MP_QSTR_flush), MP_ROM_PTR(&PTR_OBJ(display_flush)) }, { MP_ROM_QSTR(MP_QSTR_touch_read), MP_ROM_PTR(&PTR_OBJ(touch_read)) }, // for test start { MP_ROM_QSTR(MP_QSTR_draw), MP_ROM_PTR(&mp_display_draw_obj) }, { MP_ROM_QSTR(MP_QSTR_monkey_test), MP_ROM_PTR(&mp_monkey_test) }, // for test end }; STATIC MP_DEFINE_CONST_DICT(mp_module_display_globals, display_globals_table); const mp_obj_module_t mp_module_lvgl_display = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t*)&mp_module_display_globals }; MP_REGISTER_MODULE(MP_QSTR_lvgl_display, mp_module_lvgl_display, MICROPY_PY_LVGL);
YifuLiu/AliOS-Things
components/py_engine/modules/display/esp32/moddisplay.c
C
apache-2.0
8,221
/* * This file is part of the MicroPython ESP32 project, https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo * * The MIT License (MIT) * * Copyright (c) 2018 LoBo (https://github.com/loboris) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include "sdkconfig.h" #include <stdio.h> #include <string.h> #include <ctype.h> #include <sys/time.h> #include "py/mperrno.h" #include "py/mphal.h" #include "py/runtime.h" #include "modmachine.h" #include "tft/tftspi.h" #include "tft/tft.h" #include "driver/mcpwm.h" #include "soc/mcpwm_reg.h" #include "soc/mcpwm_struct.h" typedef struct _display_tft_obj_t { mp_obj_base_t base; display_config_t dconfig; exspi_device_handle_t *disp_spi; mp_obj_t expwm_handler; } display_tft_obj_t; display_tft_obj_t *tft_save = NULL; const mp_obj_type_t display_tft_type; extern uint8_t disp_used_spi_host; extern exspi_device_handle_t *disp_spi; // constructor(id, ...) //----------------------------------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { display_tft_obj_t *self = m_new_obj(display_tft_obj_t); uint8_t lcd_init_state = 0; if(disp_spi == NULL) { disp_spi = (exspi_device_handle_t *)malloc(sizeof(exspi_device_handle_t)); } else { lcd_init_state = 1; } self->base.type = &display_tft_type; self->disp_spi = disp_spi; self->dconfig.speed = 40000000; self->dconfig.rdspeed = 2000000; self->dconfig.type = DISP_TYPE_M5STACK; self->dconfig.host = HSPI_HOST; self->dconfig.mosi = 23; self->dconfig.miso = 38; self->dconfig.sck = 18; self->dconfig.cs = 5; self->dconfig.dc = 15; self->dconfig.tcs = -1; self->dconfig.rst = -1; self->dconfig.bckl = -1; self->dconfig.bckl_on = 1; self->dconfig.color_bits = 16; self->dconfig.gamma = 0; self->dconfig.width = 320; self->dconfig.height = 240; self->dconfig.invrot = 3; self->dconfig.bgr = 8; self->dconfig.touch = TOUCH_TYPE_NONE; if (lcd_init_state == 0) { TFT_display_init(&self->dconfig); spi_set_speed(disp_spi, self->dconfig.speed); } font_rotate = 0; text_wrap = 1; font_transparent = 1; font_forceFixed = 0; gray_scale = 0; TFT_resetclipwin(); TFT_setFont(DEFAULT_FONT, NULL); TFT_fillScreen(TFT_BLACK); return MP_OBJ_FROM_PTR(self); } //----------------------------------------------------------------------------------------------- STATIC void display_tft_printinfo(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { mp_printf(print, "TFT (Color mode: 16-bit, Clk=40000000 Hz)\n"); mp_printf(print, "Pins (miso=38, mosi=23, clk=18, cs=5, dc=15, reset by axp192)"); } //-------------------------------------- STATIC color_t intToColor(uint32_t cint) { color_t cl = {0,0,0}; cl.r = (cint >> 16) & 0xFF; cl.g = (cint >> 8) & 0xFF; cl.b = cint & 0xFF; return cl; } // STATIC uint16_t* StrToUnicode(const byte* str, size_t str_len, size_t* utf_len) { // uint16_t len; // len = utf8_charlen(str, str_len); // if(len == 0) { // return NULL; // } // uint16_t* code = calloc(len, sizeof(uint16_t)); // if (code == NULL) { // return NULL; // } // for (uint16_t i = 0; i < len; i++) { // code[i] = utf8_get_char(str); // str = utf8_next_char(str); // } // *utf_len = len; // return code; // } //------------------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_drawPixel(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { const mp_arg_t allowed_args[] = { { MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_color, MP_ARG_INT, { .u_int = -1 } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); color_t color = _fg; mp_int_t x = args[0].u_int; mp_int_t y = args[1].u_int; if (args[2].u_int >= 0) { color = intToColor(args[2].u_int); } TFT_drawPixel(x, y, color, 1); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_drawPixel_obj, 2, display_tft_drawPixel); //------------------------------------------------------------------------------------------------ STATIC mp_obj_t display_tft_drawLine(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { const mp_arg_t allowed_args[] = { { MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_x1, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_y1, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_color, MP_ARG_INT, { .u_int = -1 } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); color_t color = _fg; mp_int_t x0 = args[0].u_int; mp_int_t y0 = args[1].u_int; mp_int_t x1 = args[2].u_int; mp_int_t y1 = args[3].u_int; if (args[4].u_int >= 0) { color = intToColor(args[4].u_int); } TFT_drawLine(x0, y0, x1, y1, color); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_drawLine_obj, 4, display_tft_drawLine); #if 0 //------------------------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_drawLineByAngle(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { const mp_arg_t allowed_args[] = { { MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_start, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_length, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_angle, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_color, MP_ARG_INT, { .u_int = -1 } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); color_t color = _fg; mp_int_t x = args[0].u_int; mp_int_t y = args[1].u_int; mp_int_t start = args[2].u_int; mp_int_t len = args[3].u_int; mp_int_t angle = args[4].u_int; if (args[5].u_int >= 0) { color = intToColor(args[5].u_int); } TFT_drawLineByAngle(x, y, start, len, angle, color); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_drawLineByAngle_obj, 5, display_tft_drawLineByAngle); //---------------------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_drawTriangle(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { const mp_arg_t allowed_args[] = { { MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_x1, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_y1, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_x2, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_y2, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_color, MP_ARG_INT, { .u_int = -1 } }, { MP_QSTR_fillcolor, MP_ARG_INT, { .u_int = -1 } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); color_t color = _fg; mp_int_t x0 = args[0].u_int; mp_int_t y0 = args[1].u_int; mp_int_t x1 = args[2].u_int; mp_int_t y1 = args[3].u_int; mp_int_t x2 = args[4].u_int; mp_int_t y2 = args[5].u_int; if (args[6].u_int >= 0) { color = intToColor(args[6].u_int); } if (args[7].u_int >= 0) { TFT_fillTriangle(x0, y0, x1, y1, x2, y2, intToColor(args[7].u_int)); } TFT_drawTriangle(x0, y0, x1, y1, x2, y2, color); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_drawTriangle_obj, 6, display_tft_drawTriangle); //---------------------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_fillTriangle(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { const mp_arg_t allowed_args[] = { { MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_x1, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_y1, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_x2, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_y2, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_color, MP_ARG_INT, { .u_int = -1 } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); color_t color = _fg; mp_int_t x0 = args[0].u_int; mp_int_t y0 = args[1].u_int; mp_int_t x1 = args[2].u_int; mp_int_t y1 = args[3].u_int; mp_int_t x2 = args[4].u_int; mp_int_t y2 = args[5].u_int; if (args[6].u_int >= 0) { color = intToColor(args[6].u_int); } TFT_fillTriangle(x0, y0, x1, y1, x2, y2, color); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_fillTriangle_obj, 6, display_tft_fillTriangle); //-------------------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_drawCircle(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { const mp_arg_t allowed_args[] = { { MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_r, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_color, MP_ARG_INT, { .u_int = -1 } }, { MP_QSTR_fillcolor, MP_ARG_INT, { .u_int = -1 } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); color_t color = _fg; mp_int_t x = args[0].u_int; mp_int_t y = args[1].u_int; mp_int_t radius = args[2].u_int; if (args[3].u_int >= 0) { color = intToColor(args[3].u_int); } if (args[4].u_int >= 0) { TFT_fillCircle(x, y, radius, intToColor(args[4].u_int)); if (args[3].u_int != args[4].u_int) TFT_drawCircle(x, y, radius, color); } else TFT_drawCircle(x, y, radius, color); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_drawCircle_obj, 3, display_tft_drawCircle); //-------------------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_fillCircle(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { const mp_arg_t allowed_args[] = { { MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_r, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_color, MP_ARG_INT, { .u_int = -1 } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); color_t color = _fg; mp_int_t x = args[0].u_int; mp_int_t y = args[1].u_int; mp_int_t radius = args[2].u_int; if (args[3].u_int >= 0) { color = intToColor(args[3].u_int); } TFT_fillCircle(x, y, radius, color); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_fillCircle_obj, 3, display_tft_fillCircle); //-------------------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_drawSwitchBtn(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { const mp_arg_t allowed_args[] = { { MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_w, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_h, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_color, MP_ARG_INT, { .u_int = -1 } }, { MP_QSTR_switch_color, MP_ARG_INT, { .u_int = -1 } }, { MP_QSTR_state, MP_ARG_INT, { .u_int = 0 } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); color_t color = _fg; color_t switch_color = _fg; mp_int_t x = args[0].u_int; mp_int_t y = args[1].u_int; mp_int_t w = args[2].u_int; mp_int_t h = args[3].u_int; mp_int_t state = args[6].u_int; if (args[4].u_int >= 0) { color = intToColor(args[4].u_int); } if (args[5].u_int >= 0) { switch_color = intToColor(args[5].u_int); } else { switch_color = color; } TFT_drawSwitchBtn(x, y, w, h, color, switch_color, state); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_drawSwitchBtn_obj, 4, display_tft_drawSwitchBtn); //--------------------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_drawEllipse(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { const mp_arg_t allowed_args[] = { { MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_rx, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_ry, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_opt, MP_ARG_INT, { .u_int = 15 } }, { MP_QSTR_color, MP_ARG_INT, { .u_int = -1 } }, { MP_QSTR_fillcolor, MP_ARG_INT, { .u_int = -1 } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); color_t color = _fg; mp_int_t x = args[0].u_int; mp_int_t y = args[1].u_int; mp_int_t rx = args[2].u_int; mp_int_t ry = args[3].u_int; mp_int_t opt = args[4].u_int & 0x0F; if (args[5].u_int >= 0) { color = intToColor(args[5].u_int); } if (args[6].u_int >= 0) { TFT_fillEllipse(x, y, rx, ry, intToColor(args[6].u_int), opt); } TFT_drawEllipse(x, y, rx, ry, color, opt); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_drawEllipse_obj, 4, display_tft_drawEllipse); //----------------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_drawArc(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { const mp_arg_t allowed_args[] = { { MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_r, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_thick, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_start, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_end, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 15 } }, { MP_QSTR_color, MP_ARG_INT, { .u_int = -1 } }, { MP_QSTR_fillcolor, MP_ARG_INT, { .u_int = -1 } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); color_t color = _fg; color_t fill_color = _fg; mp_int_t x = args[0].u_int; mp_int_t y = args[1].u_int; mp_int_t r = args[2].u_int; mp_int_t th = args[3].u_int; mp_int_t start = args[4].u_int; mp_int_t end = args[5].u_int; if (args[6].u_int >= 0) { color = intToColor(args[6].u_int); } if (args[7].u_int >= 0) { fill_color = intToColor(args[7].u_int); } TFT_drawArc(x, y, r, th, start, end, color, fill_color); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_drawArc_obj, 6, display_tft_drawArc); //------------------------------------------------------------------------------------------------ STATIC mp_obj_t display_tft_drawPoly(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { const mp_arg_t allowed_args[] = { { MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_r, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_sides, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_thick, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 1 } }, { MP_QSTR_color, MP_ARG_INT, { .u_int = -1 } }, { MP_QSTR_fillcolor, MP_ARG_INT, { .u_int = -1 } }, { MP_QSTR_rotate, MP_ARG_INT, { .u_int = 0 } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); color_t color = _fg; color_t fill_color = _fg; mp_int_t x = args[0].u_int; mp_int_t y = args[1].u_int; mp_int_t r = args[2].u_int; mp_int_t sides = args[3].u_int; mp_int_t th = args[4].u_int; if (args[5].u_int >= 0) { color = intToColor(args[5].u_int); } if (args[6].u_int >= 0) { fill_color = intToColor(args[6].u_int); } TFT_drawPolygon(x, y, sides, r, color, fill_color, args[7].u_int, th); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_drawPoly_obj, 5, display_tft_drawPoly); #endif //------------------------------------------------------------------------------------------------ STATIC mp_obj_t display_tft_drawRect(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { const mp_arg_t allowed_args[] = { { MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_width, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_height, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_color, MP_ARG_INT, { .u_int = -1 } }, { MP_QSTR_fillcolor, MP_ARG_INT, { .u_int = -1 } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); color_t color = _fg; mp_int_t x = args[0].u_int; mp_int_t y = args[1].u_int; mp_int_t w = args[2].u_int; mp_int_t h = args[3].u_int; if (args[4].u_int >= 0) { color = intToColor(args[4].u_int); } if (args[5].u_int >= 0) { TFT_fillRect(x, y, w, h, intToColor(args[5].u_int)); } TFT_drawRect(x, y, w, h, color); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_drawRect_obj, 4, display_tft_drawRect); //------------------------------------------------------------------------------------------------ STATIC mp_obj_t display_tft_fillRect(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { const mp_arg_t allowed_args[] = { { MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_width, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_height, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_color, MP_ARG_INT, { .u_int = -1 } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_int_t x = args[0].u_int; mp_int_t y = args[1].u_int; mp_int_t w = args[2].u_int; mp_int_t h = args[3].u_int; color_t color = _fg; if (args[4].u_int >= 0) { color = intToColor(args[4].u_int); } TFT_fillRect(x, y, w, h, color); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_fillRect_obj, 4, display_tft_fillRect); #if 0 //------------------------------------------------------------------------------------------------ STATIC mp_obj_t display_tft_qrcode(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { const mp_arg_t allowed_args[] = { { MP_QSTR_text, MP_ARG_REQUIRED | MP_ARG_OBJ, { .u_obj = mp_const_none } }, { MP_QSTR_x, MP_ARG_INT, { .u_int = 50 } }, { MP_QSTR_y, MP_ARG_INT, { .u_int = 10 } }, { MP_QSTR_width, MP_ARG_INT, { .u_int = 220 } }, { MP_QSTR_version, MP_ARG_INT, { .u_int = 6 } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); char *text = (char *)mp_obj_str_get_str(args[0].u_obj); mp_int_t x = args[1].u_int; mp_int_t y = args[2].u_int; mp_int_t width = args[3].u_int; mp_int_t version = args[4].u_int; // Create the QR code QRCode qrcode; uint8_t qrcodeData[qrcode_getBufferSize(version)]; qrcode_initText(&qrcode, qrcodeData, version, 0, text); // Top quiet zone uint8_t thickness = width / qrcode.size; uint16_t lineLength = qrcode.size * thickness; uint8_t xOffset = x + (width-lineLength)/2; uint8_t yOffset = y + (width-lineLength)/2; TFT_fillRect(x, y, width, width, TFT_WHITE); for (uint8_t y = 0; y < qrcode.size; y++) { for (uint8_t x = 0; x < qrcode.size; x++) { uint8_t q = qrcode_getModule(&qrcode, x, y); if (q) { TFT_fillRect(x * thickness + xOffset, y * thickness + yOffset, thickness, thickness, TFT_BLACK); } } } return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_qrcode_obj, 1, display_tft_qrcode); //----------------------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_drawRoundRect(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { const mp_arg_t allowed_args[] = { { MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_width, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_height, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_r, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_color, MP_ARG_INT, { .u_int = -1 } }, { MP_QSTR_fillcolor, MP_ARG_INT, { .u_int = -1 } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); color_t color = _fg; mp_int_t x = args[0].u_int; mp_int_t y = args[1].u_int; mp_int_t w = args[2].u_int; mp_int_t h = args[3].u_int; mp_int_t r = args[4].u_int; if (args[5].u_int >= 0) { color = intToColor(args[5].u_int); } if (args[6].u_int >= 0) { TFT_fillRoundRect(x, y, w, h, r, intToColor(args[6].u_int)); } TFT_drawRoundRect(x, y, w, h, r, color); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_drawRoundRect_obj, 5, display_tft_drawRoundRect); //----------------------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_fillRoundRect(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { const mp_arg_t allowed_args[] = { { MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_width, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_height, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_r, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_color, MP_ARG_INT, { .u_int = -1 } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); color_t color = _fg; mp_int_t x = args[0].u_int; mp_int_t y = args[1].u_int; mp_int_t w = args[2].u_int; mp_int_t h = args[3].u_int; mp_int_t r = args[4].u_int; if (args[5].u_int >= 0) { color = intToColor(args[5].u_int); } TFT_fillRoundRect(x, y, w, h, r, color); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_fillRoundRect_obj, 5, display_tft_fillRoundRect); #endif //-------------------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_fillScreen(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { const mp_arg_t allowed_args[] = { { MP_QSTR_color, MP_ARG_INT, { .u_int = -1 } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); color_t color = _bg; if (args[0].u_int >= 0) { color = intToColor(args[0].u_int); } TFT_fillScreen(color); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_fillScreen_obj, 0, display_tft_fillScreen); //----------------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_fillWin(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { const mp_arg_t allowed_args[] = { { MP_QSTR_color, MP_ARG_INT, { .u_int = -1 } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); color_t color = _bg; if (args[0].u_int >= 0) { color = intToColor(args[0].u_int); } TFT_fillWindow(color); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_fillWin_obj, 0, display_tft_fillWin); //-------------------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_7segAttrib(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { const mp_arg_t allowed_args[] = { { MP_QSTR_dist, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_width, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_outline, MP_ARG_REQUIRED | MP_ARG_BOOL, { .u_bool = false } }, { MP_QSTR_color, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = -1 } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); set_7seg_font_atrib(args[0].u_int, args[1].u_int, (int)args[2].u_bool, intToColor(args[3].u_int)); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_7segAttrib_obj, 4, display_tft_7segAttrib); //----------------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_setFont(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { const mp_arg_t allowed_args[] = { { MP_QSTR_font, MP_ARG_REQUIRED | MP_ARG_OBJ, { .u_obj = mp_const_none } }, { MP_QSTR_rotate, MP_ARG_KW_ONLY | MP_ARG_INT, { .u_int = -1 } }, { MP_QSTR_transparent, MP_ARG_KW_ONLY | MP_ARG_INT, { .u_int = -1 } }, { MP_QSTR_fixedwidth, MP_ARG_KW_ONLY | MP_ARG_INT, { .u_int = -1 } }, { MP_QSTR_dist, MP_ARG_KW_ONLY | MP_ARG_INT, { .u_int = 8 } }, { MP_QSTR_width, MP_ARG_KW_ONLY | MP_ARG_INT, { .u_int = 2 } }, { MP_QSTR_outline, MP_ARG_KW_ONLY | MP_ARG_BOOL, { .u_bool = false } }, { MP_QSTR_color, MP_ARG_KW_ONLY | MP_ARG_INT, { .u_int = 0 } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); const char *font_file = NULL; // char fullname[128] = {'\0'}; mp_int_t font = DEFAULT_FONT; if (MP_OBJ_IS_STR(args[0].u_obj)) { font_file = mp_obj_str_get_str(args[0].u_obj); // if (physicalPath(font_file, fullname) == 0) { font = USER_FONT; // font_file = fullname; // } } else { font = mp_obj_get_int(args[0].u_obj); } TFT_setFont(font, font_file); if (args[1].u_int >= 0) font_rotate = args[1].u_int; if (args[2].u_int >= 0) font_transparent = args[2].u_int & 1; if (args[3].u_int >= 0) font_forceFixed = args[3].u_int & 1; if (font == FONT_7SEG) { set_7seg_font_atrib(args[4].u_int, args[5].u_int, (int)args[6].u_bool, intToColor(args[7].u_int)); } return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_setFont_obj, 1, display_tft_setFont); //------------------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_getFontSize(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { int width, height; TFT_getfontsize(&width, &height); mp_obj_t tuple[2]; tuple[0] = mp_obj_new_int(width); tuple[1] = mp_obj_new_int(height); return mp_obj_new_tuple(2, tuple); } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_getFontSize_obj, 0, display_tft_getFontSize); //----------------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_setRot(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { const mp_arg_t allowed_args[] = { { MP_QSTR_rot, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = PORTRAIT } }, }; display_tft_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_int_t rot = args[0].u_int; if ((rot < 0) || (rot > 3)) rot = 0; TFT_setRotation(rot); self->dconfig.width = _width; self->dconfig.height = _height; return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_setRot_obj, 1, display_tft_setRot); //--------------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_text(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { const mp_arg_t allowed_args[] = { { MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_text, MP_ARG_REQUIRED | MP_ARG_OBJ, { .u_obj = mp_const_none } }, { MP_QSTR_color, MP_ARG_INT, { .u_int = -1 } }, { MP_QSTR_rotate, MP_ARG_KW_ONLY | MP_ARG_INT, { .u_int = -1 } }, { MP_QSTR_transparent, MP_ARG_KW_ONLY | MP_ARG_INT, { .u_int = -1 } }, { MP_QSTR_fixedwidth, MP_ARG_KW_ONLY | MP_ARG_INT, { .u_int = -1 } }, { MP_QSTR_wrap, MP_ARG_KW_ONLY | MP_ARG_INT, { .u_int = -1 } }, { MP_QSTR_bgcolor, MP_ARG_KW_ONLY | MP_ARG_INT, { .u_int = -1 } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); color_t old_fg = _fg; color_t old_bg = _bg; int old_rot = font_rotate; int old_transp = font_transparent; int old_fixed = font_forceFixed; int old_wrap = text_wrap; mp_int_t x = args[0].u_int; mp_int_t y = args[1].u_int; if (args[3].u_int >= 0) _fg = intToColor(args[3].u_int); if (args[4].u_int >= 0) font_rotate = args[4].u_int; if (args[5].u_int >= 0) font_transparent = args[5].u_int & 1; if (args[6].u_int >= 0) font_forceFixed = args[6].u_int & 1; if (args[7].u_int >= 0) text_wrap = args[7].u_int & 1; if (args[8].u_int >= 0) _bg = intToColor(args[8].u_int); // if(font_now == UNICODE_FONT) { // size_t len; // const byte *str = (const byte *)mp_obj_str_get_data(args[2].u_obj, &len); // uint16_t* code = StrToUnicode(str, len, &len); // if(code == NULL) { // return mp_const_none; // } // TFT_print_unicode(code, len, x, y); // free(code); // } else { char *st = (char *)mp_obj_str_get_str(args[2].u_obj); TFT_print(st, x, y); // } _fg = old_fg; _bg = old_bg; font_rotate = old_rot; font_transparent = old_transp; font_forceFixed = old_fixed; text_wrap = old_wrap; return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_text_obj, 3, display_tft_text); //--------------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_print(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { const mp_arg_t allowed_args[] = { { MP_QSTR_text, MP_ARG_REQUIRED | MP_ARG_OBJ, { .u_obj = mp_const_none } }, { MP_QSTR_x, MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_y, MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_color, MP_ARG_INT, { .u_int = -1 } }, { MP_QSTR_rotate, MP_ARG_KW_ONLY | MP_ARG_INT, { .u_int = -1 } }, { MP_QSTR_transparent, MP_ARG_KW_ONLY | MP_ARG_OBJ, { .u_obj = mp_const_none } }, { MP_QSTR_fixedwidth, MP_ARG_KW_ONLY | MP_ARG_OBJ, { .u_obj = mp_const_none } }, { MP_QSTR_wrap, MP_ARG_KW_ONLY | MP_ARG_OBJ, { .u_obj = mp_const_none } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); color_t old_fg = _fg; mp_int_t x; mp_int_t y; if (n_args > 2) { x = args[1].u_int; y = args[2].u_int; } else { x = TFT_X; y = TFT_Y; } if (args[3].u_int >= 0) { _fg = intToColor(args[3].u_int); } if (args[4].u_int >= 0) font_rotate = args[4].u_int; if (mp_obj_is_integer(args[5].u_obj)) font_transparent = args[5].u_int; if (mp_obj_is_integer(args[6].u_obj)) font_forceFixed = args[6].u_int; if (mp_obj_is_integer(args[7].u_obj)) text_wrap = args[7].u_int; char* st; size_t len; if (MP_OBJ_IS_STR(args[0].u_obj)) { st = (char *)mp_obj_str_get_data(args[0].u_obj, &len); } else { char str[32]; if (mp_obj_is_integer(args[0].u_obj)) { int num = mp_obj_get_int(args[0].u_obj); sprintf(str, "%d", num); } else if (mp_obj_is_float(args[0].u_obj)) { float f = mp_obj_float_get(args[0].u_obj); sprintf(str, "%f", f); } st = str; len = strlen(st); } // if(font_now == UNICODE_FONT) { // uint16_t* code = StrToUnicode((byte *)st, len, &len); // if(code == NULL) { // return mp_const_none; // } // TFT_print_unicode(code, len, x, y); // free(code); // } else { TFT_print(st, x, y); // } _fg = old_fg; return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_print_obj, 1, display_tft_print); //--------------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_println(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { display_tft_print(n_args, pos_args, kw_args); TFT_print("\r\n", TFT_X, TFT_Y); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_println_obj, 1, display_tft_println); //--------------------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_stringWidth(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { const mp_arg_t allowed_args[] = { { MP_QSTR_text, MP_ARG_REQUIRED | MP_ARG_OBJ, { .u_obj = mp_const_none } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_int_t w = 0; // if(font_now == UNICODE_FONT) { // size_t len = 0; // const byte *st = (const byte *)mp_obj_str_get_data(args[0].u_obj, &len); // uint16_t* code = StrToUnicode(st, len, &len); // if(code == NULL) { // w = -1; // } else { // for (uint16_t i = 0; i < len; i++) { // w += GetUnicodeWidth(code[i]) + 1; // } // free(code); // } // } else { char *st = (char *)mp_obj_str_get_str(args[0].u_obj); w = TFT_getStringWidth(st); // } return mp_obj_new_int(w); } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_stringWidth_obj, 1, display_tft_stringWidth); //------------------------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_clearStringRect(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { const mp_arg_t allowed_args[] = { { MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_text, MP_ARG_REQUIRED | MP_ARG_OBJ, { .u_obj = mp_const_none } }, { MP_QSTR_color, MP_ARG_INT, { .u_int = -1 } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); color_t old_bg = _bg; mp_int_t x = args[0].u_int; mp_int_t y = args[1].u_int; char *st = (char *)mp_obj_str_get_str(args[2].u_obj); if (args[3].u_int >= 0) _bg = intToColor(args[3].u_int); TFT_clearStringRect(x, y, st); _bg = old_bg; return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_clearStringRect_obj, 3, display_tft_clearStringRect); STATIC mp_obj_t display_tft_Image_buff(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { const mp_arg_t allowed_args[] = { { MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_file, MP_ARG_REQUIRED | MP_ARG_OBJ, { .u_obj = mp_const_none } }, { MP_QSTR_scale, MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_type, MP_ARG_INT, { .u_int = -1 } }, { MP_QSTR_DEBUG, MP_ARG_KW_ONLY | MP_ARG_INT, { .u_int = 0 } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); image_debug = (uint8_t)args[5].u_bool; mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[2].u_obj, &bufinfo, MP_BUFFER_READ); if (bufinfo.len < 20) { return mp_const_none; } uint8_t* buf_ptr = (uint8_t *)bufinfo.buf; if (buf_ptr[0] == 0xff && buf_ptr[1] == 0xd8 && buf_ptr[6] == 'J' && buf_ptr[7] == 'F') { TFT_jpg_image(args[0].u_int, args[1].u_int, args[3].u_int, NULL, bufinfo.buf, bufinfo.len); } #if 0 else if(buf_ptr[0] == 'B' && buf_ptr[1] == 'M') { TFT_bmp_image(args[0].u_int, args[1].u_int, args[3].u_int, NULL, bufinfo.buf, bufinfo.len); }else if(buf_ptr[1] == 'P' && buf_ptr[2] == 'N'){ TFT_png_image(args[0].u_int, args[1].u_int, args[3].u_int, NULL, bufinfo.buf, bufinfo.len); } #endif return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_Image_buff_obj, 3, display_tft_Image_buff); //----------------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_Image(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { const mp_arg_t allowed_args[] = { { MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_file, MP_ARG_REQUIRED | MP_ARG_OBJ, { .u_obj = mp_const_none } }, { MP_QSTR_scale, MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_type, MP_ARG_INT, { .u_int = -1 } }, { MP_QSTR_DEBUG, MP_ARG_KW_ONLY | MP_ARG_INT, { .u_int = 0 } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); if(!mp_obj_is_str(args[2].u_obj)) { return display_tft_Image_buff(n_args, pos_args, kw_args); } char *fname = NULL; char fullname[128] = {'\0'}; int img_type = args[4].u_int; fname = (char *)mp_obj_str_get_str(args[2].u_obj); int res = 0; //physicalPath(fname, fullname); strcpy(fullname, fname); if ((res != 0) || (strlen(fullname) == 0)) { mp_raise_msg_varg(&mp_type_OSError, MP_ERROR_TEXT("Error resolving file name")); } if (img_type < 0) { // try to determine image type char upr_fname[128]; strcpy(upr_fname, fname); for (int i=0; i < strlen(upr_fname); i++) { upr_fname[i] = toupper((unsigned char) upr_fname[i]); } if (strstr(upr_fname, ".JPG") != NULL) img_type = IMAGE_TYPE_JPG; else if (strstr(upr_fname, ".BMP") != NULL) img_type = IMAGE_TYPE_BMP; else if (strstr(upr_fname, ".PNG") != NULL) img_type = IMAGE_TYPE_PNG; if (img_type < 0) { mp_raise_msg_varg(&mp_type_OSError, MP_ERROR_TEXT("Cannot determine image type")); } } image_debug = (uint8_t)args[5].u_bool; #if 0 if (img_type == IMAGE_TYPE_BMP) { TFT_bmp_image(args[0].u_int, args[1].u_int, args[3].u_int, fullname, NULL, 0); } else #endif if (img_type == IMAGE_TYPE_JPG) { TFT_jpg_image(args[0].u_int, args[1].u_int, args[3].u_int, fullname, NULL, 0); } #if 0 else if (img_type == IMAGE_TYPE_PNG) { TFT_png_image(args[0].u_int, args[1].u_int, args[3].u_int, fullname, NULL, 0); } #endif else { mp_raise_msg_varg(&mp_type_OSError, MP_ERROR_TEXT("Unsupported image type")); } return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_Image_obj, 3, display_tft_Image); #if 0 //----------------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_compileFont(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { const mp_arg_t allowed_args[] = { { MP_QSTR_file, MP_ARG_REQUIRED | MP_ARG_OBJ, { .u_obj = mp_const_none } }, { MP_QSTR_deMP_QSTR_DEBUGbug, MP_ARG_KW_ONLY | MP_ARG_BOOL, { .u_bool = false } }, }; // // mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); char *fname = NULL; char fullname[128] = {'\0'}; uint8_t debug = (uint8_t)args[1].u_bool; fname = (char *)mp_obj_str_get_str(args[0].u_obj); int res = 0; // physicalPath(fname, fullname); strcpy(fullname, fname); if ((res != 0) || (strlen(fullname) == 0)) { mp_raise_msg_varg(&mp_type_OSError, MP_ERROR_TEXT("Error resolving file name")); } res = compile_font_file(fullname, debug); if (res) return mp_const_false; return mp_const_true; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_compileFont_obj, 1, display_tft_compileFont); //----------------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_HSBtoRGB(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { const mp_arg_t allowed_args[] = { { MP_QSTR_hue, MP_ARG_REQUIRED | MP_ARG_OBJ, { .u_obj = mp_const_none } }, { MP_QSTR_saturation, MP_ARG_REQUIRED | MP_ARG_OBJ, { .u_obj = mp_const_none } }, { MP_QSTR_brightness, MP_ARG_REQUIRED | MP_ARG_OBJ, { .u_obj = mp_const_none } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_float_t hue = mp_obj_get_float(args[0].u_obj); mp_float_t sat = mp_obj_get_float(args[1].u_obj); mp_float_t bri = mp_obj_get_float(args[2].u_obj); color_t color = HSBtoRGB(hue, sat, bri); mp_int_t icolor = (int)((color.r << 16) | (color.g << 8) | color.b); return mp_obj_new_int(icolor); } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_HSBtoRGB_obj, 3, display_tft_HSBtoRGB); //-------------------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_setclipwin(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { const mp_arg_t allowed_args[] = { { MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_x1, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_y1, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_fillcolor, MP_ARG_INT, { .u_int = -1 } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_int_t x0 = args[0].u_int; mp_int_t y0 = args[1].u_int; mp_int_t x1 = args[2].u_int; mp_int_t y1 = args[3].u_int; TFT_setclipwin(x0, y0, x1, y1); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_setclipwin_obj, 4, display_tft_setclipwin); //---------------------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_resetclipwin(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { TFT_resetclipwin(); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_resetclipwin_obj, 0, display_tft_resetclipwin); //--------------------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_saveclipwin(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { TFT_saveClipWin(); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_saveclipwin_obj, 0, display_tft_saveclipwin); //------------------------------------------------------------------------------------------------------ STATIC mp_obj_t display_tft_restoreclipwin(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { TFT_restoreClipWin(); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_restoreclipwin_obj, 0, display_tft_restoreclipwin); //------------------------------------------------------------------------------------------------ STATIC mp_obj_t display_tft_getSize(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { mp_obj_t tuple[2]; tuple[0] = mp_obj_new_int(_width); tuple[1] = mp_obj_new_int(_height); return mp_obj_new_tuple(2, tuple); } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_getSize_obj, 0, display_tft_getSize); //-------------------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_getWinSize(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { mp_obj_t tuple[2]; tuple[0] = mp_obj_new_int(dispWin.x2 - dispWin.x1 + 1); tuple[1] = mp_obj_new_int(dispWin.y2 - dispWin.y1 + 1); return mp_obj_new_tuple(2, tuple); } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_getWinSize_obj, 0, display_tft_getWinSize); #endif //------------------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_setColor(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { const mp_arg_t allowed_args[] = { { MP_QSTR_color, MP_ARG_INT, { .u_int = -1 } }, { MP_QSTR_bcolor, MP_ARG_INT, { .u_int = -1 } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); if (args[0].u_int >= 0) { _fg = intToColor(args[0].u_int); } else { _fg = intToColor(iTFT_WHITE); } if (args[1].u_int >= 0) { _bg = intToColor(args[1].u_int); } return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_setColor_obj, 0, display_tft_setColor); #if 0 //----------------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_setCursor(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { const mp_arg_t allowed_args[] = { { MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_int_t x = args[0].u_int; mp_int_t y = args[1].u_int; TFT_X = x; TFT_Y = y; return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_setCursor_obj, 2, display_tft_setCursor); //------------------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_getCursor(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { mp_obj_t tuple[2]; tuple[0] = mp_obj_new_int(TFT_X); tuple[1] = mp_obj_new_int(TFT_Y); return mp_obj_new_tuple(2, tuple); } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_getCursor_obj, 0, display_tft_getCursor); //----------------------------------------------------------------------------------------------- // STATIC mp_obj_t display_tft_setBrightness(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) // { // const mp_arg_t allowed_args[] = { // { MP_QSTR_duty, MP_ARG_REQUIRED | MP_ARG_INT, { .u_int = 0 } }, // }; // mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; // mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); // mp_int_t dperc = args[0].u_int; // if (dperc > 100) dperc = 100; // if (dperc < 0) dperc = 0; // mcpwm_set_duty_in_us(MCPWM_UNIT_0, MCPWM_TIMER_0, MCPWM_OPR_A, dperc); // return mp_const_none; // } // STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_setBrightness_obj, 0, display_tft_setBrightness); //------------------------------------------------------------------------ // STATIC mp_obj_t display_tft_backlight(mp_obj_t self_in, mp_obj_t onoff_in) // { // display_tft_obj_t *self = self_in; // int onoff = mp_obj_get_int(onoff_in); // if (onoff) bcklOn(&self->dconfig); // else bcklOff(&self->dconfig); // return mp_const_none; // } // STATIC MP_DEFINE_CONST_FUN_OBJ_2(display_tft_backlight_obj, display_tft_backlight); //------------------------------------------------------ // STATIC mp_obj_t display_tft_touch_type(mp_obj_t self_in) // { // display_tft_obj_t *self = self_in; // return mp_obj_new_int(self->dconfig.touch); // } // STATIC MP_DEFINE_CONST_FUN_OBJ_1(display_tft_touch_type_obj, display_tft_touch_type); // ==== Low level functions ====================================== //------------------------------------------------------------------------ STATIC mp_obj_t display_tft_set_speed(mp_obj_t self_in, mp_obj_t speed_in) { display_tft_obj_t *self = self_in; int speed = mp_obj_get_int(speed_in); // Set SPI clock used for display operations self->dconfig.speed = spi_set_speed(self->disp_spi, speed); // max_rdclock = find_rd_speed(); self->dconfig.rdspeed = 8000000; mp_obj_t tuple[2]; tuple[0] = mp_obj_new_int(self->dconfig.speed); tuple[1] = mp_obj_new_int(self->dconfig.rdspeed); return mp_obj_new_tuple(2, tuple); } STATIC MP_DEFINE_CONST_FUN_OBJ_2(display_tft_set_speed_obj, display_tft_set_speed); //-------------------------------------------------- STATIC mp_obj_t display_tft_select(mp_obj_t self_in) { disp_select(); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(display_tft_select_obj, display_tft_select); //---------------------------------------------------- STATIC mp_obj_t display_tft_deselect(mp_obj_t self_in) { disp_deselect(); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(display_tft_deselect_obj, display_tft_deselect); //-------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_cmd_read(mp_obj_t self_in, mp_obj_t cmd_in, mp_obj_t len_in) { uint8_t cmd = (uint8_t)mp_obj_get_int(cmd_in); uint8_t len = (uint8_t)mp_obj_get_int(len_in); if ((len < 1) || (len > 4)) len = 1; uint32_t res = read_cmd(cmd, len); return mp_obj_new_int_from_uint(res); } STATIC MP_DEFINE_CONST_FUN_OBJ_3(display_tft_cmd_read_obj, display_tft_cmd_read); //------------------------------------------------------------------------- STATIC mp_obj_t display_tft_send_command(mp_obj_t self_in, mp_obj_t cmd_in) { uint8_t cmd = (uint8_t)mp_obj_get_int(cmd_in); disp_select(); disp_spi_transfer_cmd(cmd); wait_trans_finish(0); disp_deselect(); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(display_tft_send_command_obj, display_tft_send_command); //-------------------------------------------------------------------------------------------- STATIC mp_obj_t display_tft_send_cmd_data(mp_obj_t self_in, mp_obj_t cmd_in, mp_obj_t data_in) { uint8_t cmd = (uint8_t)mp_obj_get_int(cmd_in); mp_buffer_info_t data; mp_get_buffer_raise(data_in, &data, MP_BUFFER_READ); disp_select(); disp_spi_transfer_cmd_data(cmd, data.buf, data.len); wait_trans_finish(0); disp_deselect(); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(display_tft_send_cmd_data_obj, display_tft_send_cmd_data); //-------------------------------------------------- STATIC mp_obj_t display_tft_get_bg(mp_obj_t self_in) { int icolor = (int)((_bg.r << 16) | (_bg.g << 8) | _bg.b); return mp_obj_new_int(icolor); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(display_tft_get_bg_obj, display_tft_get_bg); //-------------------------------------------------- STATIC mp_obj_t display_tft_get_fg(mp_obj_t self_in) { int icolor = (int)((_fg.r << 16) | (_fg.g << 8) | _fg.b); return mp_obj_new_int(icolor); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(display_tft_get_fg_obj, display_tft_get_fg); //--------------------------------------------------------------------- STATIC mp_obj_t display_tft_set_bg(mp_obj_t self_in, mp_obj_t color_in) { color_t color = intToColor(mp_obj_get_int(color_in)); _bg = color; return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(display_tft_set_bg_obj, display_tft_set_bg); //--------------------------------------------------------------------- STATIC mp_obj_t display_tft_set_fg(mp_obj_t self_in, mp_obj_t color_in) { color_t color = intToColor(mp_obj_get_int(color_in)); _fg = color; return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(display_tft_set_fg_obj, display_tft_set_fg); //------------------------------------------------- STATIC mp_obj_t display_tft_get_X(mp_obj_t self_in) { int x = TFT_X; return mp_obj_new_int(x); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(display_tft_get_X_obj, display_tft_get_X); //------------------------------------------------- STATIC mp_obj_t display_tft_get_Y(mp_obj_t self_in) { int y = TFT_Y; return mp_obj_new_int(y); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(display_tft_get_Y_obj, display_tft_get_Y); #endif // =============================================================== STATIC const mp_rom_map_elem_t display_tft_locals_dict_table[] = { #if 0 // instance methods // { MP_ROM_QSTR(MP_QSTR_readPixel), MP_ROM_PTR(&display_tft_readPixel_obj) }, #endif { MP_ROM_QSTR(MP_QSTR_pixel), MP_ROM_PTR(&display_tft_drawPixel_obj) }, { MP_ROM_QSTR(MP_QSTR_line), MP_ROM_PTR(&display_tft_drawLine_obj) }, #if 0 { MP_ROM_QSTR(MP_QSTR_lineByAngle), MP_ROM_PTR(&display_tft_drawLineByAngle_obj) }, { MP_ROM_QSTR(MP_QSTR_triangle), MP_ROM_PTR(&display_tft_drawTriangle_obj) }, { MP_ROM_QSTR(MP_QSTR_circle), MP_ROM_PTR(&display_tft_drawCircle_obj) }, { MP_ROM_QSTR(MP_QSTR_ellipse), MP_ROM_PTR(&display_tft_drawEllipse_obj) }, { MP_ROM_QSTR(MP_QSTR_arc), MP_ROM_PTR(&display_tft_drawArc_obj) }, { MP_ROM_QSTR(MP_QSTR_polygon), MP_ROM_PTR(&display_tft_drawPoly_obj) }, #endif { MP_ROM_QSTR(MP_QSTR_rect), MP_ROM_PTR(&display_tft_drawRect_obj) }, #if 0 // { MP_ROM_QSTR(MP_QSTR_readScreen), MP_ROM_PTR(&display_tft_readScreen_obj) }, { MP_ROM_QSTR(MP_QSTR_roundrect), MP_ROM_PTR(&display_tft_drawRoundRect_obj) }, #endif { MP_ROM_QSTR(MP_QSTR_clear), MP_ROM_PTR(&display_tft_fillScreen_obj) }, { MP_ROM_QSTR(MP_QSTR_fill), MP_ROM_PTR(&display_tft_fillScreen_obj) }, { MP_ROM_QSTR(MP_QSTR_clearwin), MP_ROM_PTR(&display_tft_fillWin_obj) }, { MP_ROM_QSTR(MP_QSTR_font), MP_ROM_PTR(&display_tft_setFont_obj) }, { MP_ROM_QSTR(MP_QSTR_fontSize), MP_ROM_PTR(&display_tft_getFontSize_obj) }, { MP_ROM_QSTR(MP_QSTR_text), MP_ROM_PTR(&display_tft_text_obj) }, { MP_ROM_QSTR(MP_QSTR_orient), MP_ROM_PTR(&display_tft_setRot_obj) }, { MP_ROM_QSTR(MP_QSTR_textWidth), MP_ROM_PTR(&display_tft_stringWidth_obj) }, { MP_ROM_QSTR(MP_QSTR_textClear), MP_ROM_PTR(&display_tft_clearStringRect_obj) }, #if 0 { MP_ROM_QSTR(MP_QSTR_attrib7seg), MP_ROM_PTR(&display_tft_7segAttrib_obj) }, #endif { MP_ROM_QSTR(MP_QSTR_image), MP_ROM_PTR(&display_tft_Image_obj) }, { MP_ROM_QSTR(MP_QSTR_image_buff), MP_ROM_PTR(&display_tft_Image_buff_obj) }, // { MP_ROM_QSTR(MP_QSTR_gettouch), MP_ROM_PTR(&display_tft_getTouch_obj) }, #if 0 { MP_ROM_QSTR(MP_QSTR_compileFont), MP_ROM_PTR(&display_tft_compileFont_obj) }, { MP_ROM_QSTR(MP_QSTR_hsb2rgb), MP_ROM_PTR(&display_tft_HSBtoRGB_obj) }, { MP_ROM_QSTR(MP_QSTR_setwin), MP_ROM_PTR(&display_tft_setclipwin_obj) }, { MP_ROM_QSTR(MP_QSTR_resetwin), MP_ROM_PTR(&display_tft_resetclipwin_obj) }, { MP_ROM_QSTR(MP_QSTR_savewin), MP_ROM_PTR(&display_tft_saveclipwin_obj) }, { MP_ROM_QSTR(MP_QSTR_restorewin), MP_ROM_PTR(&display_tft_restoreclipwin_obj) }, { MP_ROM_QSTR(MP_QSTR_screensize), MP_ROM_PTR(&display_tft_getSize_obj) }, { MP_ROM_QSTR(MP_QSTR_winsize), MP_ROM_PTR(&display_tft_getWinSize_obj) }, { MP_ROM_QSTR(MP_QSTR_get_fg), MP_ROM_PTR(&display_tft_get_fg_obj) }, { MP_ROM_QSTR(MP_QSTR_get_bg), MP_ROM_PTR(&display_tft_get_bg_obj) }, { MP_ROM_QSTR(MP_QSTR_set_fg), MP_ROM_PTR(&display_tft_set_fg_obj) }, { MP_ROM_QSTR(MP_QSTR_set_bg), MP_ROM_PTR(&display_tft_set_bg_obj) }, { MP_ROM_QSTR(MP_QSTR_text_x), MP_ROM_PTR(&display_tft_get_X_obj) }, { MP_ROM_QSTR(MP_QSTR_text_y), MP_ROM_PTR(&display_tft_get_Y_obj) }, { MP_ROM_QSTR(MP_QSTR_setColor), MP_ROM_PTR(&display_tft_setColor_obj) }, #endif // Adafruit API { MP_ROM_QSTR(MP_QSTR_print), MP_ROM_PTR(&display_tft_print_obj) }, { MP_ROM_QSTR(MP_QSTR_println), MP_ROM_PTR(&display_tft_println_obj) }, { MP_ROM_QSTR(MP_QSTR_setRotation), MP_ROM_PTR(&display_tft_setRot_obj) }, { MP_ROM_QSTR(MP_QSTR_setTextColor), MP_ROM_PTR(&display_tft_setColor_obj) }, #if 0 { MP_ROM_QSTR(MP_QSTR_setCursor), MP_ROM_PTR(&display_tft_setCursor_obj) }, { MP_ROM_QSTR(MP_QSTR_getCursor), MP_ROM_PTR(&display_tft_getCursor_obj) }, { MP_ROM_QSTR(MP_QSTR_fillScreen), MP_ROM_PTR(&display_tft_fillScreen_obj) }, #endif { MP_ROM_QSTR(MP_QSTR_drawPixel), MP_ROM_PTR(&display_tft_drawPixel_obj) }, { MP_ROM_QSTR(MP_QSTR_drawLine), MP_ROM_PTR(&display_tft_drawLine_obj) }, { MP_ROM_QSTR(MP_QSTR_drawRect), MP_ROM_PTR(&display_tft_drawRect_obj) }, { MP_ROM_QSTR(MP_QSTR_fillRect), MP_ROM_PTR(&display_tft_fillRect_obj) }, #if 0 { MP_ROM_QSTR(MP_QSTR_drawCircle), MP_ROM_PTR(&display_tft_drawCircle_obj) }, { MP_ROM_QSTR(MP_QSTR_fillCircle), MP_ROM_PTR(&display_tft_fillCircle_obj) }, { MP_ROM_QSTR(MP_QSTR_drawSwitchBtn), MP_ROM_PTR(&display_tft_drawSwitchBtn_obj) }, { MP_ROM_QSTR(MP_QSTR_drawTriangle), MP_ROM_PTR(&display_tft_drawTriangle_obj) }, { MP_ROM_QSTR(MP_QSTR_fillTriangle), MP_ROM_PTR(&display_tft_fillTriangle_obj) }, { MP_ROM_QSTR(MP_QSTR_drawRoundRect), MP_ROM_PTR(&display_tft_drawRoundRect_obj) }, { MP_ROM_QSTR(MP_QSTR_fillRoundRect), MP_ROM_PTR(&display_tft_fillRoundRect_obj) }, // { MP_ROM_QSTR(MP_QSTR_setBrightness), MP_ROM_PTR(&display_tft_setBrightness_obj) }, // { MP_ROM_QSTR(MP_QSTR_backlight), MP_ROM_PTR(&display_tft_setBrightness_obj) }, { MP_ROM_QSTR(MP_QSTR_qrcode), MP_ROM_PTR(&display_tft_qrcode_obj) }, { MP_ROM_QSTR(MP_QSTR_tft_setspeed), MP_ROM_PTR(&display_tft_set_speed_obj) }, { MP_ROM_QSTR(MP_QSTR_tft_select), MP_ROM_PTR(&display_tft_select_obj) }, { MP_ROM_QSTR(MP_QSTR_tft_deselect), MP_ROM_PTR(&display_tft_deselect_obj) }, { MP_ROM_QSTR(MP_QSTR_tft_writecmd), MP_ROM_PTR(&display_tft_send_command_obj) }, { MP_ROM_QSTR(MP_QSTR_tft_writecmddata), MP_ROM_PTR(&display_tft_send_cmd_data_obj) }, { MP_ROM_QSTR(MP_QSTR_tft_readcmd), MP_ROM_PTR(&display_tft_cmd_read_obj) }, { MP_ROM_QSTR(MP_QSTR_CENTER), MP_ROM_INT(CENTER) }, { MP_ROM_QSTR(MP_QSTR_RIGHT), MP_ROM_INT(RIGHT) }, { MP_ROM_QSTR(MP_QSTR_BOTTOM), MP_ROM_INT(BOTTOM) }, { MP_ROM_QSTR(MP_QSTR_LASTX), MP_ROM_INT(LASTX) }, { MP_ROM_QSTR(MP_QSTR_LASTY), MP_ROM_INT(LASTY) }, { MP_ROM_QSTR(MP_QSTR_PORTRAIT), MP_ROM_INT(PORTRAIT) }, { MP_ROM_QSTR(MP_QSTR_LANDSCAPE), MP_ROM_INT(LANDSCAPE) }, { MP_ROM_QSTR(MP_QSTR_PORTRAIT_FLIP), MP_ROM_INT(PORTRAIT_FLIP) }, { MP_ROM_QSTR(MP_QSTR_LANDSCAPE_FLIP), MP_ROM_INT(LANDSCAPE_FLIP) }, #endif { MP_ROM_QSTR(MP_QSTR_FONT_Default), MP_ROM_INT(DEFAULT_FONT) }, { MP_ROM_QSTR(MP_QSTR_FONT_DejaVu18), MP_ROM_INT(DEJAVU18_FONT) }, { MP_ROM_QSTR(MP_QSTR_FONT_DejaVu24), MP_ROM_INT(DEJAVU24_FONT) }, { MP_ROM_QSTR(MP_QSTR_FONT_DejaVu40), MP_ROM_INT(DEJAVU40_FONT) }, #if 0 { MP_ROM_QSTR(MP_QSTR_FONT_DejaVu56), MP_ROM_INT(DEJAVU56_FONT) }, { MP_ROM_QSTR(MP_QSTR_FONT_DejaVu72), MP_ROM_INT(DEJAVU72_FONT) }, { MP_ROM_QSTR(MP_QSTR_FONT_Ubuntu), MP_ROM_INT(UBUNTU16_FONT) }, { MP_ROM_QSTR(MP_QSTR_FONT_Comic), MP_ROM_INT(COMIC24_FONT) }, { MP_ROM_QSTR(MP_QSTR_FONT_Minya), MP_ROM_INT(MINYA24_FONT) }, { MP_ROM_QSTR(MP_QSTR_FONT_Tooney), MP_ROM_INT(TOONEY32_FONT) }, { MP_ROM_QSTR(MP_QSTR_FONT_Small), MP_ROM_INT(SMALL_FONT) }, { MP_ROM_QSTR(MP_QSTR_FONT_DefaultSmall), MP_ROM_INT(DEF_SMALL_FONT) }, { MP_ROM_QSTR(MP_QSTR_FONT_7seg), MP_ROM_INT(FONT_7SEG) }, // { MP_ROM_QSTR(MP_QSTR_FONT_UNICODE), MP_ROM_INT(UNICODE_FONT) }, { MP_ROM_QSTR(MP_QSTR_ICON_SetMenu), MP_ROM_INT(ICON_SETMENU) }, { MP_ROM_QSTR(MP_QSTR_ICON_Machine), MP_ROM_INT(ICON_MACHINE) }, { MP_ROM_QSTR(MP_QSTR_ICON_ListON), MP_ROM_INT(ICON_LIST_ON) }, { MP_ROM_QSTR(MP_QSTR_ICON_ListOFF), MP_ROM_INT(ICON_LIST_OFF) }, { MP_ROM_QSTR(MP_QSTR_ICON_App), MP_ROM_INT(ICON_APP) }, { MP_ROM_QSTR(MP_QSTR_ICON_AppIcon), MP_ROM_INT(ICON_APP_ICON) }, { MP_ROM_QSTR(MP_QSTR_ICON_AppMenu), MP_ROM_INT(ICON_APP_MENU) }, { MP_ROM_QSTR(MP_QSTR_ICON_Eath), MP_ROM_INT(ICON_EATH) }, { MP_ROM_QSTR(MP_QSTR_ICON_Key), MP_ROM_INT(ICON_KEY) }, { MP_ROM_QSTR(MP_QSTR_ICON_Retry), MP_ROM_INT(ICON_RETRY) }, { MP_ROM_QSTR(MP_QSTR_ICON_Setup), MP_ROM_INT(ICON_SETUP) }, { MP_ROM_QSTR(MP_QSTR_ICON_Url), MP_ROM_INT(ICON_URL) }, { MP_ROM_QSTR(MP_QSTR_ICON_Wifi), MP_ROM_INT(ICON_WIFI) }, { MP_ROM_QSTR(MP_QSTR_ICON_WifiBig), MP_ROM_INT(ICON_WIFI_BIG) }, { MP_ROM_QSTR(MP_QSTR_ICON_USB), MP_ROM_INT(ICON_USB) }, { MP_ROM_QSTR(MP_QSTR_ICON_Cloud), MP_ROM_INT(ICON_CLOUD) }, #endif { MP_ROM_QSTR(MP_QSTR_BLACK), MP_ROM_INT(iTFT_BLACK) }, { MP_ROM_QSTR(MP_QSTR_NAVY), MP_ROM_INT(iTFT_NAVY) }, { MP_ROM_QSTR(MP_QSTR_DARKGREEN), MP_ROM_INT(iTFT_DARKGREEN) }, { MP_ROM_QSTR(MP_QSTR_DARKCYAN), MP_ROM_INT(iTFT_DARKCYAN) }, { MP_ROM_QSTR(MP_QSTR_MAROON), MP_ROM_INT(iTFT_MAROON) }, { MP_ROM_QSTR(MP_QSTR_PURPLE), MP_ROM_INT(iTFT_PURPLE) }, { MP_ROM_QSTR(MP_QSTR_OLIVE), MP_ROM_INT(iTFT_OLIVE) }, { MP_ROM_QSTR(MP_QSTR_LIGHTGREY), MP_ROM_INT(iTFT_LIGHTGREY) }, { MP_ROM_QSTR(MP_QSTR_DARKGREY), MP_ROM_INT(iTFT_DARKGREY) }, { MP_ROM_QSTR(MP_QSTR_BLUE), MP_ROM_INT(iTFT_BLUE) }, { MP_ROM_QSTR(MP_QSTR_GREEN), MP_ROM_INT(iTFT_GREEN) }, { MP_ROM_QSTR(MP_QSTR_CYAN), MP_ROM_INT(iTFT_CYAN) }, { MP_ROM_QSTR(MP_QSTR_RED), MP_ROM_INT(iTFT_RED) }, { MP_ROM_QSTR(MP_QSTR_MAGENTA), MP_ROM_INT(iTFT_MAGENTA) }, { MP_ROM_QSTR(MP_QSTR_YELLOW), MP_ROM_INT(iTFT_YELLOW) }, { MP_ROM_QSTR(MP_QSTR_WHITE), MP_ROM_INT(iTFT_WHITE) }, { MP_ROM_QSTR(MP_QSTR_ORANGE), MP_ROM_INT(iTFT_ORANGE) }, { MP_ROM_QSTR(MP_QSTR_GREENYELLOW), MP_ROM_INT(iTFT_GREENYELLOW) }, { MP_ROM_QSTR(MP_QSTR_PINK), MP_ROM_INT(iTFT_PINK) }, { MP_ROM_QSTR(MP_QSTR_COLOR_BITS16), MP_ROM_INT(16) }, { MP_ROM_QSTR(MP_QSTR_COLOR_BITS24), MP_ROM_INT(24) }, { MP_ROM_QSTR(MP_QSTR_JPG), MP_ROM_INT(IMAGE_TYPE_JPG) }, { MP_ROM_QSTR(MP_QSTR_BMP), MP_ROM_INT(IMAGE_TYPE_BMP) }, { MP_ROM_QSTR(MP_QSTR_HSPI), MP_ROM_INT(HSPI_HOST) }, { MP_ROM_QSTR(MP_QSTR_VSPI), MP_ROM_INT(VSPI_HOST) }, }; STATIC MP_DEFINE_CONST_DICT(display_tft_locals_dict, display_tft_locals_dict_table); const mp_obj_type_t display_tft_type = { { &mp_type_type }, .name = MP_QSTR_TFT, .print = display_tft_printinfo, .make_new = display_tft_make_new, .locals_dict = (mp_obj_t)&display_tft_locals_dict, }; STATIC const mp_rom_map_elem_t tft_display_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_display) }, { MP_OBJ_NEW_QSTR(MP_QSTR_TFT), MP_ROM_PTR(&display_tft_type) }, }; STATIC MP_DEFINE_CONST_DICT(mp_module_tft_display_globals, tft_display_globals_table); const mp_obj_module_t mp_module_display = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t*)&mp_module_tft_display_globals }; MP_REGISTER_MODULE(MP_QSTR_display, mp_module_display, MICROPY_PY_TFT);
YifuLiu/AliOS-Things
components/py_engine/modules/display/esp32/modtft.c
C
apache-2.0
69,904
// Default font // ======================================================================== // This comes with no warranty, implied or otherwise // This data structure was designed to support Proportional fonts // fonts. Individual characters do not have to be multiples of 8 bits wide. // Any width is fine and does not need to be fixed. // The data bits are packed to minimize data requirements, but the tradeoff // is that a header is required per character. // Header Format: // ------------------------------------------------ // Character Width (Used as a marker to indicate use this format. i.e.: = 0x00) // Character Height // First Character (Reserved. 0x00) // Number Of Characters (Reserved. 0x00) // Individual Character Format: // ---------------------------- // Character Code // Adjusted Y Offset (start Y of visible pixels) // Width (width of the visible pixels) // Height (height of the visible pixels) // xOffset (start X of visible pixels) // xDelta (the distance to move the cursor. Effective width of the character.) // Data[n] // NOTE: You can remove any of these characters if they are not needed in // your application. The first character number in each Glyph indicates // the ASCII character code. Therefore, these do not have to be sequential. // Just remove all the content for a particular character to save space. // ======================================================================== // dejavu // Point Size : 12 // Memory usage : 1158 bytes // # characters : 95 #include "sdkconfig.h" const unsigned char tft_DefaultFont[] = { 0x00, 0x0B, 0x86, 0x04, // ' ' 0x20,0x0A,0x00,0x00,0x00,0x04, // '!' 0x21,0x01,0x01,0x09,0x02,0x05, 0xFD,0x80, // '"' 0x22,0x01,0x03,0x03,0x01,0x05, 0xB6,0x80, // '#' 0x23,0x02,0x08,0x08,0x01,0x0A, 0x12,0x14,0x7F,0x24,0x24,0xFE,0x28,0x48, // '$' 0x24,0x01,0x06,0x0B,0x02,0x08, 0x21,0xCA,0xA8,0xE0,0xE2,0xAA,0x70,0x82,0x00, // '%' 0x25,0x01,0x0A,0x09,0x00,0x0B, 0x61,0x24,0x89,0x22,0x50,0x6D,0x82,0x91,0x24,0x49,0x21,0x80, // '&' 0x26,0x01,0x09,0x09,0x01,0x0A, 0x30,0x24,0x10,0x0C,0x05,0x14,0x4A,0x19,0x8C,0x7B,0x00, // ''' 0x27,0x01,0x01,0x03,0x01,0x03, 0xE0, // '(' 0x28,0x00,0x03,0x0B,0x01,0x05, 0x69,0x49,0x24,0x48,0x80, // ')' 0x29,0x00,0x03,0x0B,0x01,0x05, 0x89,0x12,0x49,0x4A,0x00, // '*' 0x2A,0x01,0x05,0x06,0x01,0x06, 0x25,0x5C,0xEA,0x90, // '+' 0x2B,0x03,0x07,0x07,0x01,0x0A, 0x10,0x20,0x47,0xF1,0x02,0x04,0x00, // ',' 0x2C,0x08,0x01,0x03,0x01,0x04, 0xE0, // '-' 0x2D,0x06,0x03,0x01,0x01,0x04, 0xE0, // '.' 0x2E,0x08,0x01,0x02,0x01,0x04, 0xC0, // '/' 0x2F,0x01,0x04,0x0A,0x00,0x04, 0x11,0x22,0x24,0x44,0x88, // '0' 0x30,0x01,0x06,0x09,0x01,0x08, 0x79,0x28,0x61,0x86,0x18,0x52,0x78, // '1' 0x31,0x01,0x05,0x09,0x01,0x08, 0xE1,0x08,0x42,0x10,0x84,0xF8, // '2' 0x32,0x01,0x07,0x09,0x01,0x08, 0x79,0x18,0x10,0x20,0x82,0x08,0x20,0xFC, // '3' 0x33,0x01,0x06,0x09,0x01,0x08, 0x7A,0x10,0x41,0x38,0x30,0x63,0x78, // '4' 0x34,0x01,0x06,0x09,0x01,0x08, 0x18,0x62,0x92,0x4A,0x2F,0xC2,0x08, // '5' 0x35,0x01,0x06,0x09,0x01,0x08, 0xFA,0x08,0x3C,0x0C,0x10,0x63,0x78, // '6' 0x36,0x01,0x06,0x09,0x01,0x08, 0x39,0x18,0x3E,0xCE,0x18,0x53,0x78, // '7' 0x37,0x01,0x06,0x09,0x01,0x08, 0xFC,0x10,0x82,0x10,0x42,0x08,0x40, // '8' 0x38,0x01,0x06,0x09,0x01,0x08, 0x7B,0x38,0x73,0x7B,0x38,0x73,0x78, // '9' 0x39,0x01,0x06,0x09,0x01,0x08, 0x7B,0x28,0x61,0xCD,0xD0,0x62,0x70, // ':' 0x3A,0x04,0x01,0x06,0x01,0x04, 0xCC, // ';' 0x3B,0x04,0x01,0x07,0x01,0x04, 0xCE, // '<' 0x3C,0x03,0x08,0x06,0x01,0x0A, 0x03,0x1E,0xE0,0xE0,0x1E,0x03, // '=' 0x3D,0x05,0x08,0x03,0x01,0x0A, 0xFF,0x00,0xFF, // '>' 0x3E,0x03,0x08,0x06,0x01,0x0A, 0xC0,0x78,0x07,0x07,0x78,0xC0, // '?' 0x3F,0x01,0x05,0x09,0x00,0x06, 0x74,0x42,0x22,0x10,0x04,0x20, // '@' 0x40,0x01,0x0B,0x0B,0x01,0x0D, 0x1F,0x06,0x19,0x01,0x46,0x99,0x13,0x22,0x64,0x54,0x6C,0x40,0x04,0x10,0x7C,0x00, // 'A' 0x41,0x01,0x08,0x09,0x00,0x08, 0x18,0x18,0x24,0x24,0x24,0x42,0x7E,0x42,0x81, // 'B' 0x42,0x01,0x06,0x09,0x01,0x08, 0xFA,0x18,0x61,0xFA,0x18,0x61,0xF8, // 'C' 0x43,0x01,0x06,0x09,0x01,0x08, 0x39,0x18,0x20,0x82,0x08,0x11,0x38, // 'D' 0x44,0x01,0x07,0x09,0x01,0x09, 0xF9,0x0A,0x0C,0x18,0x30,0x60,0xC2,0xF8, // 'E' 0x45,0x01,0x06,0x09,0x01,0x08, 0xFE,0x08,0x20,0xFE,0x08,0x20,0xFC, // 'F' 0x46,0x01,0x05,0x09,0x01,0x07, 0xFC,0x21,0x0F,0xC2,0x10,0x80, // 'G' 0x47,0x01,0x07,0x09,0x01,0x09, 0x3C,0x86,0x04,0x08,0xF0,0x60,0xA1,0x3C, // 'H' 0x48,0x01,0x07,0x09,0x01,0x09, 0x83,0x06,0x0C,0x1F,0xF0,0x60,0xC1,0x82, // 'I' 0x49,0x01,0x01,0x09,0x01,0x03, 0xFF,0x80, // 'J' 0x4A,0x01,0x03,0x0B,0xFF,0x03, 0x24,0x92,0x49,0x27,0x00, // 'K' 0x4B,0x01,0x07,0x09,0x01,0x07, 0x85,0x12,0x45,0x0C,0x14,0x24,0x44,0x84, // 'L' 0x4C,0x01,0x05,0x09,0x01,0x06, 0x84,0x21,0x08,0x42,0x10,0xF8, // 'M' 0x4D,0x01,0x08,0x09,0x01,0x0A, 0x81,0xC3,0xC3,0xA5,0xA5,0x99,0x99,0x81,0x81, // 'N' 0x4E,0x01,0x07,0x09,0x01,0x09, 0xC3,0x86,0x8D,0x19,0x31,0x62,0xC3,0x86, // 'O' 0x4F,0x01,0x07,0x09,0x01,0x09, 0x38,0x8A,0x0C,0x18,0x30,0x60,0xA2,0x38, // 'P' 0x50,0x01,0x06,0x09,0x01,0x08, 0xFA,0x38,0x63,0xFA,0x08,0x20,0x80, // 'Q' 0x51,0x01,0x07,0x0B,0x01,0x09, 0x38,0x8A,0x0C,0x18,0x30,0x60,0xA2,0x38,0x10,0x10, // 'R' 0x52,0x01,0x07,0x09,0x01,0x08, 0xF9,0x1A,0x14,0x6F,0x91,0x21,0x42,0x82, // 'S' 0x53,0x01,0x06,0x09,0x01,0x08, 0x7B,0x18,0x30,0x78,0x30,0x63,0x78, // 'T' 0x54,0x01,0x07,0x09,0x00,0x07, 0xFE,0x20,0x40,0x81,0x02,0x04,0x08,0x10, // 'U' 0x55,0x01,0x07,0x09,0x01,0x09, 0x83,0x06,0x0C,0x18,0x30,0x60,0xA2,0x38, // 'V' 0x56,0x01,0x0A,0x09,0xFF,0x08, 0x40,0x90,0x22,0x10,0x84,0x21,0x04,0x81,0x20,0x30,0x0C,0x00, // 'W' 0x57,0x01,0x0B,0x09,0x00,0x0B, 0x84,0x28,0x89,0x11,0x27,0x22,0xA8,0x55,0x0E,0xE0,0x88,0x11,0x00, // 'X' 0x58,0x01,0x07,0x09,0x00,0x07, 0xC6,0x88,0xA1,0xC1,0x07,0x0A,0x22,0x82, // 'Y' 0x59,0x01,0x07,0x09,0x00,0x07, 0x82,0x89,0x11,0x43,0x82,0x04,0x08,0x10, // 'Z' 0x5A,0x01,0x07,0x09,0x01,0x09, 0xFE,0x04,0x10,0x41,0x04,0x10,0x40,0xFE, // '[' 0x5B,0x01,0x02,0x0B,0x02,0x05, 0xEA,0xAA,0xAC, // '\' 0x5C,0x01,0x04,0x0A,0x00,0x04, 0x88,0x44,0x42,0x22,0x11, // ']' 0x5D,0x01,0x02,0x0B,0x01,0x05, 0xD5,0x55,0x5C, // '^' 0x5E,0x01,0x08,0x03,0x01,0x0A, 0x18,0x24,0x42, // '_' 0x5F,0x0C,0x06,0x01,0x00,0x06, 0xFC, // '`' 0x60,0x00,0x03,0x02,0x01,0x06, 0x44, // 'a' 0x61,0x03,0x06,0x07,0x01,0x08, 0x7A,0x30,0x5F,0x86,0x37,0x40, // 'b' 0x62,0x00,0x06,0x0A,0x01,0x08, 0x82,0x08,0x2E,0xCA,0x18,0x61,0xCE,0xE0, // 'c' 0x63,0x03,0x05,0x07,0x01,0x07, 0x72,0x61,0x08,0x25,0xC0, // 'd' 0x64,0x00,0x06,0x0A,0x01,0x08, 0x04,0x10,0x5D,0xCE,0x18,0x61,0xCD,0xD0, // 'e' 0x65,0x03,0x06,0x07,0x01,0x08, 0x39,0x38,0x7F,0x81,0x13,0x80, // 'f' 0x66,0x00,0x04,0x0A,0x00,0x04, 0x34,0x4F,0x44,0x44,0x44, // 'g' 0x67,0x03,0x06,0x0A,0x01,0x08, 0x77,0x38,0x61,0x87,0x37,0x41,0x4C,0xE0, // 'h' 0x68,0x00,0x06,0x0A,0x01,0x08, 0x82,0x08,0x2E,0xC6,0x18,0x61,0x86,0x10, // 'i' 0x69,0x01,0x01,0x09,0x01,0x03, 0xBF,0x80, // 'j' 0x6A,0x01,0x02,0x0C,0x00,0x03, 0x45,0x55,0x56, // 'k' 0x6B,0x00,0x06,0x0A,0x01,0x07, 0x82,0x08,0x22,0x92,0x8E,0x28,0x92,0x20, // 'l' 0x6C,0x00,0x01,0x0A,0x01,0x03, 0xFF,0xC0, // 'm' 0x6D,0x03,0x09,0x07,0x01,0x0B, 0xB3,0x66,0x62,0x31,0x18,0x8C,0x46,0x22, // 'n' 0x6E,0x03,0x06,0x07,0x01,0x08, 0xBB,0x18,0x61,0x86,0x18,0x40, // 'o' 0x6F,0x03,0x06,0x07,0x01,0x08, 0x7B,0x38,0x61,0x87,0x37,0x80, // 'p' 0x70,0x03,0x06,0x0A,0x01,0x08, 0xBB,0x28,0x61,0x87,0x3B,0xA0,0x82,0x00, // 'q' 0x71,0x03,0x06,0x0A,0x01,0x08, 0x77,0x38,0x61,0x87,0x37,0x41,0x04,0x10, // 'r' 0x72,0x03,0x04,0x07,0x01,0x05, 0xBC,0x88,0x88,0x80, // 's' 0x73,0x03,0x06,0x07,0x01,0x07, 0x72,0x28,0x1C,0x0A,0x27,0x00, // 't' 0x74,0x01,0x04,0x09,0x00,0x05, 0x44,0xF4,0x44,0x44,0x30, // 'u' 0x75,0x03,0x06,0x07,0x01,0x08, 0x86,0x18,0x61,0x86,0x37,0x40, // 'v' 0x76,0x03,0x08,0x07,0xFF,0x06, 0x42,0x42,0x24,0x24,0x24,0x18,0x18, // 'w' 0x77,0x03,0x09,0x07,0x00,0x09, 0x88,0xC4,0x57,0x4A,0xA5,0x51,0x10,0x88, // 'x' 0x78,0x03,0x06,0x07,0x00,0x06, 0x85,0x24,0x8C,0x49,0x28,0x40, // 'y' 0x79,0x03,0x08,0x0A,0xFF,0x06, 0x42,0x42,0x24,0x24,0x14,0x18,0x08,0x08,0x10,0x60, // 'z' 0x7A,0x03,0x05,0x07,0x00,0x05, 0xF8,0x44,0x44,0x43,0xE0, // '{' 0x7B,0x01,0x05,0x0B,0x02,0x08, 0x19,0x08,0x42,0x60,0x84,0x21,0x06, // '|' 0x7C,0x01,0x01,0x0C,0x02,0x04, 0xFF,0xF0, // '}' 0x7D,0x01,0x05,0x0B,0x01,0x08, 0xC1,0x08,0x42,0x0C,0x84,0x21,0x30, // '~' 0x7E,0x04,0x08,0x03,0x01,0x0A, 0x00,0x71,0x8E, // Terminator 0xFF };
YifuLiu/AliOS-Things
components/py_engine/modules/display/esp32/tft/font/DefaultFont.c
C
apache-2.0
8,255
// ============================================================================ // Proportional font Header Format: // ------------------------------------------------ // Character Width (Used as a marker to indicate use this format. i.e.: = 0x00) // Character Height // First Character (Reserved. 0x00) // Number Of Characters (Reserved. 0x00) // Individual Character Format: // ---------------------------- // Character Code // Adjusted Y Offset // Width // Height // xOffset // xDelta (the distance to move the cursor. Effective width of the character.) // Data[n] // NOTE: You can remove any of these characters if they are not needed in // your application. The first character number in each Glyph indicates // the ASCII character code. Therefore, these do not have to be sequential. // Just remove all the content for a particular character to save space. // ============================================================================ // DejaVuSans // Point Size : 18 // Memory usage : 1828 bytes // # characters : 95 #include "sdkconfig.h" const unsigned char tft_Dejavu18[] = { 0x00, 0x12, 0x00, 0x00, // ' ' 0x20,0x0E,0x00,0x00,0x00,0x06, // '!' 0x21,0x01,0x02,0x0D,0x03,0x07, 0xFF,0xFF,0xC3,0xC0, // '"' 0x22,0x01,0x06,0x05,0x01,0x08, 0xCF,0x3C,0xF3,0xCC, // '#' 0x23,0x00,0x0C,0x0E,0x01,0x0F, 0x04,0x40,0x44,0x0C,0xC0,0xC8,0x7F,0xF7,0xFF,0x09,0x81,0x90,0xFF,0xEF,0xFE,0x13,0x03,0x30,0x32,0x02,0x20, // '$' 0x24,0x00,0x0A,0x11,0x01,0x0B, 0x08,0x02,0x03,0xE1,0xFC,0xE9,0x32,0x0F,0x81,0xF8,0x0F,0x02,0x60,0x9A,0x2E,0xFF,0x1F,0x80,0x80,0x20,0x08,0x00, // '%' 0x25,0x01,0x0F,0x0D,0x01,0x11, 0x78,0x10,0x90,0x43,0x31,0x86,0x62,0x0C,0xC8,0x19,0x10,0x1E,0x4F,0x01,0x12,0x02,0x66,0x08,0xCC,0x31,0x98,0x41,0x21,0x03,0xC0, // '&' 0x26,0x01,0x0C,0x0D,0x01,0x0D, 0x0F,0x01,0xF8,0x30,0x83,0x00,0x38,0x03,0xC0,0x7E,0x6C,0x76,0xC3,0xCC,0x18,0xE1,0xC7,0xFE,0x3E,0x70, // ''' 0x27,0x01,0x02,0x05,0x01,0x04, 0xFF,0xC0, // '(' 0x28,0x00,0x04,0x10,0x02,0x07, 0x32,0x66,0x4C,0xCC,0xCC,0xC4,0x66,0x23, // ')' 0x29,0x00,0x04,0x10,0x01,0x07, 0xC4,0x66,0x23,0x33,0x33,0x32,0x66,0x4C, // '*' 0x2A,0x01,0x07,0x08,0x01,0x09, 0x11,0x25,0x51,0xC3,0x8A,0xA4,0x88, // '+' 0x2B,0x02,0x0C,0x0C,0x02,0x0F, 0x06,0x00,0x60,0x06,0x00,0x60,0x06,0x0F,0xFF,0xFF,0xF0,0x60,0x06,0x00,0x60,0x06,0x00,0x60, // ',' 0x2C,0x0C,0x03,0x04,0x01,0x06, 0x6D,0x40, // '-' 0x2D,0x08,0x05,0x02,0x01,0x07, 0xFF,0xC0, // '.' 0x2E,0x0C,0x02,0x02,0x02,0x06, 0xF0, // '/' 0x2F,0x01,0x06,0x0F,0x00,0x06, 0x0C,0x31,0x86,0x18,0xE3,0x0C,0x31,0xC6,0x18,0x63,0x0C,0x00, // '0' 0x30,0x01,0x09,0x0D,0x01,0x0B, 0x3E,0x3F,0x98,0xD8,0x3C,0x1E,0x0F,0x07,0x83,0xC1,0xE0,0xD8,0xCF,0xE3,0xE0, // '1' 0x31,0x01,0x08,0x0D,0x02,0x0B, 0x38,0xF8,0xD8,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xFF,0xFF, // '2' 0x32,0x01,0x09,0x0D,0x01,0x0B, 0x7C,0x7F,0x21,0xC0,0x60,0x30,0x30,0x18,0x18,0x18,0x18,0x18,0x1F,0xEF,0xF0, // '3' 0x33,0x01,0x09,0x0D,0x01,0x0B, 0x7E,0x7F,0xA0,0xE0,0x30,0x39,0xF0,0xFC,0x07,0x01,0x80,0xE0,0xFF,0xE7,0xE0, // '4' 0x34,0x01,0x0A,0x0D,0x01,0x0B, 0x07,0x01,0xC0,0xB0,0x6C,0x13,0x08,0xC6,0x31,0x0C,0xFF,0xFF,0xF0,0x30,0x0C,0x03,0x00, // '5' 0x35,0x01,0x08,0x0D,0x01,0x0B, 0x7E,0x7E,0x60,0x60,0x7C,0x7E,0x47,0x03,0x03,0x03,0x87,0xFE,0x7C, // '6' 0x36,0x01,0x09,0x0D,0x01,0x0B, 0x1E,0x1F,0x9C,0x5C,0x0C,0x06,0xF3,0xFD,0xC7,0xC1,0xE0,0xD8,0xEF,0xE1,0xE0, // '7' 0x37,0x01,0x08,0x0D,0x01,0x0B, 0xFF,0xFF,0x06,0x06,0x06,0x0E,0x0C,0x0C,0x1C,0x18,0x18,0x38,0x30, // '8' 0x38,0x01,0x09,0x0D,0x01,0x0B, 0x3E,0x3F,0xB8,0xF8,0x3E,0x39,0xF1,0xFD,0xC7,0xC1,0xE0,0xF8,0xEF,0xE3,0xE0, // '9' 0x39,0x01,0x09,0x0D,0x01,0x0B, 0x3C,0x3F,0xB8,0xD8,0x3C,0x1F,0x1D,0xFE,0x7B,0x01,0x81,0xD1,0xCF,0xC3,0xC0, // ':' 0x3A,0x05,0x02,0x09,0x02,0x06, 0xF0,0x03,0xC0, // ';' 0x3B,0x05,0x03,0x0B,0x01,0x06, 0x6C,0x00,0x03,0x6A,0x00, // '<' 0x3C,0x04,0x0B,0x0A,0x02,0x0F, 0x00,0x20,0x3C,0x1F,0x1F,0x0F,0x81,0xF0,0x0F,0x80,0x3E,0x01,0xE0,0x04, // '=' 0x3D,0x05,0x0B,0x06,0x02,0x0F, 0xFF,0xFF,0xFC,0x00,0x00,0x0F,0xFF,0xFF,0xC0, // '>' 0x3E,0x04,0x0B,0x0A,0x02,0x0F, 0x80,0x1E,0x01,0xF0,0x07,0xC0,0x3E,0x07,0xC3,0xE3,0xE0,0xF0,0x10,0x00, // '?' 0x3F,0x01,0x07,0x0D,0x01,0x0A, 0x79,0xFA,0x38,0x30,0x61,0x86,0x18,0x30,0x60,0x01,0x83,0x00, // '@' 0x40,0x01,0x10,0x10,0x01,0x12, 0x07,0xE0,0x1F,0xF8,0x3C,0x1C,0x70,0x06,0x60,0x07,0xE3,0x63,0xC7,0xE3,0xC6,0x63,0xC6,0x66,0xC7,0xFC,0xE3,0x70,0x60,0x00,0x70,0x00,0x3C,0x30,0x1F,0xF0,0x07,0xC0, // 'A' 0x41,0x01,0x0C,0x0D,0x00,0x0C, 0x06,0x00,0x60,0x0F,0x00,0xF0,0x19,0x81,0x98,0x19,0x83,0x0C,0x3F,0xC7,0xFE,0x60,0x66,0x06,0xC0,0x30, // 'B' 0x42,0x01,0x09,0x0D,0x02,0x0C, 0xFC,0x7F,0xB0,0xD8,0x6C,0x37,0xF3,0xF9,0x86,0xC1,0xE0,0xF0,0xFF,0xEF,0xE0, // 'C' 0x43,0x01,0x0B,0x0D,0x01,0x0D, 0x0F,0xC7,0xFD,0xC0,0xB0,0x0C,0x01,0x80,0x30,0x06,0x00,0xC0,0x0C,0x01,0xC0,0x9F,0xF0,0xFC, // 'D' 0x44,0x01,0x0B,0x0D,0x02,0x0E, 0xFE,0x1F,0xF3,0x07,0x60,0x6C,0x07,0x80,0xF0,0x1E,0x03,0xC0,0x78,0x1B,0x07,0x7F,0xCF,0xE0, // 'E' 0x45,0x01,0x08,0x0D,0x02,0x0B, 0xFF,0xFF,0xC0,0xC0,0xC0,0xFF,0xFF,0xC0,0xC0,0xC0,0xC0,0xFF,0xFF, // 'F' 0x46,0x01,0x08,0x0D,0x02,0x0A, 0xFF,0xFF,0xC0,0xC0,0xC0,0xFE,0xFE,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0, // 'G' 0x47,0x01,0x0B,0x0D,0x01,0x0E, 0x0F,0xC7,0xFD,0xC0,0xB0,0x0C,0x01,0x87,0xF0,0xFE,0x03,0xC0,0x6C,0x0D,0xC1,0x9F,0xE0,0xF8, // 'H' 0x48,0x01,0x0A,0x0D,0x02,0x0E, 0xC0,0xF0,0x3C,0x0F,0x03,0xC0,0xFF,0xFF,0xFF,0x03,0xC0,0xF0,0x3C,0x0F,0x03,0xC0,0xC0, // 'I' 0x49,0x01,0x02,0x0D,0x02,0x06, 0xFF,0xFF,0xFF,0xC0, // 'J' 0x4A,0x01,0x05,0x11,0xFF,0x06, 0x18,0xC6,0x31,0x8C,0x63,0x18,0xC6,0x31,0x8C,0xFE,0xE0, // 'K' 0x4B,0x01,0x0B,0x0D,0x02,0x0C, 0xC1,0x98,0x63,0x18,0x66,0x0D,0x81,0xE0,0x3C,0x06,0xC0,0xCC,0x18,0xC3,0x0C,0x60,0xCC,0x0C, // 'L' 0x4C,0x01,0x08,0x0D,0x02,0x0A, 0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xFF,0xFF, // 'M' 0x4D,0x01,0x0C,0x0D,0x02,0x10, 0xE0,0x7F,0x0F,0xF0,0xFD,0x8B,0xD9,0xBD,0x9B,0xCF,0x3C,0xF3,0xC6,0x3C,0x63,0xC0,0x3C,0x03,0xC0,0x30, // 'N' 0x4E,0x01,0x0A,0x0D,0x02,0x0E, 0xE0,0xF8,0x3F,0x0F,0xC3,0xD8,0xF6,0x3C,0xCF,0x1B,0xC6,0xF0,0xFC,0x3F,0x07,0xC1,0xC0, // 'O' 0x4F,0x01,0x0C,0x0D,0x01,0x0E, 0x1F,0x83,0xFC,0x70,0xE6,0x06,0xC0,0x3C,0x03,0xC0,0x3C,0x03,0xC0,0x36,0x06,0x70,0xE3,0xFC,0x1F,0x80, // 'P' 0x50,0x01,0x08,0x0D,0x02,0x0B, 0xFC,0xFE,0xC7,0xC3,0xC3,0xC7,0xFE,0xFC,0xC0,0xC0,0xC0,0xC0,0xC0, // 'Q' 0x51,0x01,0x0C,0x0F,0x01,0x0E, 0x1F,0x83,0xFC,0x70,0xE6,0x06,0xC0,0x3C,0x03,0xC0,0x3C,0x03,0xC0,0x36,0x06,0x70,0xE3,0xFC,0x1F,0x80,0x18,0x00,0xC0, // 'R' 0x52,0x01,0x0A,0x0D,0x02,0x0D, 0xFC,0x3F,0x8C,0x73,0x0C,0xC3,0x31,0xCF,0xE3,0xF0,0xC6,0x30,0xCC,0x33,0x06,0xC1,0xC0, // 'S' 0x53,0x01,0x0A,0x0D,0x01,0x0B, 0x3E,0x1F,0xCE,0x13,0x00,0xC0,0x1F,0x03,0xF0,0x0E,0x01,0x80,0x68,0x3B,0xFC,0x7E,0x00, // 'T' 0x54,0x01,0x0C,0x0D,0x00,0x0C, 0xFF,0xFF,0xFF,0x06,0x00,0x60,0x06,0x00,0x60,0x06,0x00,0x60,0x06,0x00,0x60,0x06,0x00,0x60,0x06,0x00, // 'U' 0x55,0x01,0x0A,0x0D,0x02,0x0E, 0xC0,0xF0,0x3C,0x0F,0x03,0xC0,0xF0,0x3C,0x0F,0x03,0xC0,0xF0,0x36,0x19,0xFE,0x1E,0x00, // 'V' 0x56,0x01,0x0C,0x0D,0x00,0x0C, 0xC0,0x36,0x06,0x60,0x66,0x06,0x30,0xC3,0x0C,0x19,0x81,0x98,0x19,0x80,0xF0,0x0F,0x00,0x60,0x06,0x00, // 'W' 0x57,0x01,0x11,0x0D,0x01,0x13, 0xC1,0xC1,0xE0,0xE0,0xD8,0xF8,0xCC,0x6C,0x66,0x36,0x33,0x1B,0x18,0xD8,0xD8,0x6C,0x6C,0x36,0x36,0x1F,0x1F,0x07,0x07,0x03,0x83,0x81,0xC1,0xC0, // 'X' 0x58,0x01,0x0B,0x0D,0x01,0x0D, 0x70,0xE6,0x18,0xE6,0x0D,0xC0,0xF0,0x1C,0x03,0x80,0x78,0x1B,0x07,0x30,0xC7,0x30,0x6E,0x0E, // 'Y' 0x59,0x01,0x0C,0x0D,0x00,0x0C, 0xE0,0x76,0x06,0x30,0xC1,0x98,0x19,0x80,0xF0,0x06,0x00,0x60,0x06,0x00,0x60,0x06,0x00,0x60,0x06,0x00, // 'Z' 0x5A,0x01,0x0B,0x0D,0x01,0x0D, 0xFF,0xFF,0xFC,0x07,0x01,0xC0,0x30,0x0E,0x03,0x80,0xE0,0x18,0x06,0x01,0xC0,0x7F,0xFF,0xFE, // '[' 0x5B,0x00,0x04,0x10,0x01,0x07, 0xFF,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xFF, // '\' 0x5C,0x01,0x06,0x0F,0x00,0x06, 0xC3,0x06,0x18,0x61,0xC3,0x0C,0x30,0xE1,0x86,0x18,0x30,0xC0, // ']' 0x5D,0x00,0x04,0x10,0x02,0x07, 0xFF,0x33,0x33,0x33,0x33,0x33,0x33,0xFF, // '^' 0x5E,0x01,0x0B,0x05,0x02,0x0F, 0x0E,0x03,0xE0,0xC6,0x30,0x6C,0x06, // '_' 0x5F,0x10,0x09,0x02,0x00,0x09, 0xFF,0xFF,0xC0, // '`' 0x60,0x00,0x04,0x03,0x02,0x09, 0xC6,0x30, // 'a' 0x61,0x04,0x08,0x0A,0x01,0x0A, 0x3C,0x7E,0x47,0x03,0x3F,0xFF,0xC3,0xC7,0xFF,0x7B, // 'b' 0x62,0x00,0x09,0x0E,0x02,0x0B, 0xC0,0x60,0x30,0x18,0x0D,0xE7,0xFB,0x8F,0x83,0xC1,0xE0,0xF0,0x7C,0x7F,0xF6,0xF0, // 'c' 0x63,0x04,0x08,0x0A,0x01,0x09, 0x1E,0x7F,0x61,0xC0,0xC0,0xC0,0xC0,0x61,0x7F,0x1E, // 'd' 0x64,0x00,0x09,0x0E,0x01,0x0B, 0x01,0x80,0xC0,0x60,0x33,0xDB,0xFF,0x8F,0x83,0xC1,0xE0,0xF0,0x7C,0x77,0xF9,0xEC, // 'e' 0x65,0x04,0x0A,0x0A,0x01,0x0B, 0x1F,0x1F,0xE6,0x1F,0x03,0xFF,0xFF,0xFC,0x01,0x81,0x7F,0xC7,0xE0, // 'f' 0x66,0x00,0x07,0x0E,0x00,0x06, 0x1E,0x7C,0xC1,0x8F,0xFF,0xCC,0x18,0x30,0x60,0xC1,0x83,0x06,0x00, // 'g' 0x67,0x04,0x09,0x0E,0x01,0x0B, 0x3D,0xBF,0xF8,0xF8,0x3C,0x1E,0x0F,0x07,0xC7,0x7F,0x9E,0xC0,0x68,0x67,0xF1,0xF0, // 'h' 0x68,0x00,0x08,0x0E,0x02,0x0B, 0xC0,0xC0,0xC0,0xC0,0xDE,0xFE,0xE7,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3, // 'i' 0x69,0x00,0x02,0x0E,0x02,0x05, 0xF0,0xFF,0xFF,0xF0, // 'j' 0x6A,0x00,0x04,0x12,0x00,0x05, 0x33,0x00,0x33,0x33,0x33,0x33,0x33,0x33,0xEC, // 'k' 0x6B,0x00,0x09,0x0E,0x02,0x0A, 0xC0,0x60,0x30,0x18,0x0C,0x36,0x33,0x31,0xB0,0xF0,0x78,0x36,0x19,0x8C,0x66,0x18, // 'l' 0x6C,0x00,0x02,0x0E,0x02,0x05, 0xFF,0xFF,0xFF,0xF0, // 'm' 0x6D,0x04,0x0E,0x0A,0x02,0x11, 0xDC,0x7B,0xFB,0xEE,0x79,0xF0,0xC3,0xC3,0x0F,0x0C,0x3C,0x30,0xF0,0xC3,0xC3,0x0F,0x0C,0x30, // 'n' 0x6E,0x04,0x08,0x0A,0x02,0x0B, 0xDE,0xFE,0xE7,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3, // 'o' 0x6F,0x04,0x0A,0x0A,0x01,0x0B, 0x1E,0x1F,0xE6,0x1B,0x03,0xC0,0xF0,0x3C,0x0D,0x86,0x7F,0x87,0x80, // 'p' 0x70,0x04,0x09,0x0E,0x02,0x0B, 0xDE,0x7F,0xB8,0xF8,0x3C,0x1E,0x0F,0x07,0xC7,0xFF,0x6F,0x30,0x18,0x0C,0x06,0x00, // 'q' 0x71,0x04,0x09,0x0E,0x01,0x0B, 0x3D,0xBF,0xF8,0xF8,0x3C,0x1E,0x0F,0x07,0xC7,0x7F,0x9E,0xC0,0x60,0x30,0x18,0x0C, // 'r' 0x72,0x04,0x06,0x0A,0x02,0x08, 0xDF,0xFE,0x30,0xC3,0x0C,0x30,0xC3,0x00, // 's' 0x73,0x04,0x08,0x0A,0x01,0x08, 0x7C,0xFE,0xC2,0xE0,0x7C,0x1E,0x06,0x86,0xFE,0x78, // 't' 0x74,0x01,0x06,0x0D,0x01,0x07, 0x61,0x86,0x3F,0xFD,0x86,0x18,0x61,0x86,0x1F,0x3C, // 'u' 0x75,0x04,0x08,0x0A,0x02,0x0B, 0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xE7,0x7F,0x7B, // 'v' 0x76,0x04,0x0C,0x0A,0x00,0x0B, 0x60,0x66,0x06,0x30,0xC3,0x0C,0x19,0x81,0x98,0x19,0x80,0xF0,0x0F,0x00,0x60, // 'w' 0x77,0x04,0x0F,0x0A,0x01,0x10, 0x63,0x8C,0xC7,0x19,0x8E,0x31,0xB6,0xC3,0x6D,0x86,0xDB,0x0F,0x1E,0x0E,0x38,0x1C,0x70,0x38,0xE0, // 'x' 0x78,0x04,0x0A,0x0A,0x01,0x0B, 0xE1,0xD8,0x63,0x30,0xCC,0x1E,0x07,0x83,0x30,0xCC,0x61,0xB8,0x70, // 'y' 0x79,0x04,0x0C,0x0E,0x00,0x0B, 0x60,0x66,0x06,0x30,0xC3,0x0C,0x19,0x81,0x98,0x0F,0x00,0xF0,0x06,0x00,0x60,0x06,0x00,0xC0,0x3C,0x03,0x80, // 'z' 0x7A,0x04,0x08,0x0A,0x01,0x09, 0xFF,0xFF,0x06,0x0C,0x1C,0x38,0x30,0x70,0xFF,0xFF, // '{' 0x7B,0x00,0x08,0x11,0x02,0x0B, 0x0F,0x1F,0x18,0x18,0x18,0x18,0x38,0xF0,0xF0,0x38,0x18,0x18,0x18,0x18,0x18,0x1F,0x0F, // '|' 0x7C,0x00,0x02,0x12,0x02,0x06, 0xFF,0xFF,0xFF,0xFF,0xF0, // '}' 0x7D,0x00,0x08,0x11,0x02,0x0B, 0xF0,0xF8,0x18,0x18,0x18,0x18,0x1C,0x0F,0x0F,0x1C,0x18,0x18,0x18,0x18,0x18,0xF8,0xF0, // '~' 0x7E,0x05,0x0B,0x05,0x02,0x0F, 0x00,0x0F,0x87,0xFF,0xC3,0xE0,0x00, // Terminator 0xFF };
YifuLiu/AliOS-Things
components/py_engine/modules/display/esp32/tft/font/DejaVuSans18.c
C
apache-2.0
11,114
// ======================================================================== // This comes with no warranty, implied or otherwise // This data structure was designed to support Proportional fonts // fonts. Individual characters do not have to be multiples of 8 bits wide. // Any width is fine and does not need to be fixed. // The data bits are packed to minimize data requirements, but the tradeoff // is that a header is required per character. // Header Format: // ------------------------------------------------ // Character Width (Used as a marker to indicate use this format. i.e.: = 0x00) // Character Height // First Character (Reserved. 0x00) // Number Of Characters (Reserved. 0x00) // Individual Character Format: // ---------------------------- // Character Code // Adjusted Y Offset // Width // Height // xOffset // xDelta (the distance to move the cursor. Effective width of the character.) // Data[n] // NOTE: You can remove any of these characters if they are not needed in // your application. The first character number in each Glyph indicates // the ASCII character code. Therefore, these do not have to be sequential. // Just remove all the content for a particular character to save space. // ======================================================================== // dejavu // Point Size : 24 // Memory usage : 2724 bytes // # characters : 95 #include "sdkconfig.h" const unsigned char tft_Dejavu24[] = { 0x00, 0x17, 0x00, 0x00, // ' ' 0x20,0x13,0x00,0x00,0x00,0x08, // '!' 0x21,0x01,0x02,0x12,0x04,0x0A, 0xFF,0xFF,0xFF,0x03,0xF0, // '"' 0x22,0x01,0x06,0x07,0x02,0x0B, 0xCF,0x3C,0xF3,0xCF,0x3C,0xC0, // '#' 0x23,0x01,0x10,0x12,0x02,0x14, 0x03,0x08,0x03,0x18,0x03,0x18,0x03,0x18,0x02,0x18,0x7F,0xFF,0x7F,0xFF,0x06,0x30,0x04,0x30,0x0C,0x20,0x0C,0x60,0xFF,0xFE,0xFF,0xFE,0x18,0x40,0x18,0xC0,0x18,0xC0,0x18,0xC0,0x10,0xC0, // '$' 0x24,0x01,0x0B,0x16,0x02,0x0F, 0x04,0x00,0x80,0x10,0x0F,0xC7,0xFD,0xC8,0xB1,0x06,0x20,0xE4,0x0F,0x80,0xFE,0x03,0xE0,0x4E,0x08,0xC1,0x1E,0x27,0xFF,0xC7,0xE0,0x10,0x02,0x00,0x40,0x08,0x00, // '%' 0x25,0x01,0x14,0x12,0x01,0x17, 0x3C,0x03,0x06,0x60,0x60,0xC3,0x06,0x0C,0x30,0xC0,0xC3,0x1C,0x0C,0x31,0x80,0xC3,0x38,0x0C,0x33,0x00,0x66,0x63,0xC3,0xC6,0x66,0x00,0xCC,0x30,0x1C,0xC3,0x01,0x8C,0x30,0x38,0xC3,0x03,0x0C,0x30,0x60,0xC3,0x06,0x06,0x60,0xC0,0x3C, // '&' 0x26,0x01,0x10,0x12,0x01,0x13, 0x07,0xC0,0x1F,0xE0,0x38,0x20,0x30,0x00,0x30,0x00,0x30,0x00,0x18,0x00,0x1C,0x00,0x3E,0x00,0x77,0x06,0xE3,0x86,0xC1,0xCC,0xC0,0xFC,0xC0,0x78,0xE0,0x78,0x70,0xFC,0x3F,0xCE,0x0F,0x87, // ''' 0x27,0x01,0x02,0x07,0x02,0x07, 0xFF,0xFC, // '(' 0x28,0x01,0x05,0x15,0x02,0x09, 0x19,0x8C,0xC6,0x31,0x18,0xC6,0x31,0x8C,0x61,0x0C,0x63,0x0C,0x61,0x80, // ')' 0x29,0x01,0x05,0x15,0x02,0x09, 0xC3,0x18,0x63,0x18,0x43,0x18,0xC6,0x31,0x8C,0x46,0x31,0x98,0xCC,0x00, // '*' 0x2A,0x01,0x0B,0x0A,0x00,0x0C, 0x04,0x00,0x83,0x11,0xBA,0xE1,0xF0,0x3E,0x1D,0x76,0x23,0x04,0x00,0x80, // '+' 0x2B,0x03,0x10,0x10,0x03,0x14, 0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0xFF,0xFF,0xFF,0xFF,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80, // ',' 0x2C,0x10,0x03,0x06,0x02,0x08, 0x6D,0xBD,0x80, // '-' 0x2D,0x0B,0x06,0x02,0x01,0x09, 0xFF,0xF0, // '.' 0x2E,0x10,0x02,0x03,0x03,0x08, 0xFC, // '/' 0x2F,0x01,0x08,0x14,0x00,0x08, 0x03,0x07,0x06,0x06,0x06,0x0C,0x0C,0x0C,0x18,0x18,0x18,0x18,0x30,0x30,0x30,0x60,0x60,0x60,0xE0,0xC0, // '0' 0x30,0x01,0x0C,0x12,0x02,0x0F, 0x0F,0x03,0xFC,0x70,0xE6,0x06,0x60,0x6C,0x03,0xC0,0x3C,0x03,0xC0,0x3C,0x03,0xC0,0x3C,0x03,0xC0,0x36,0x06,0x60,0x67,0x0E,0x3F,0xC0,0xF0, // '1' 0x31,0x01,0x0A,0x12,0x03,0x0F, 0x3C,0x3F,0x0C,0xC0,0x30,0x0C,0x03,0x00,0xC0,0x30,0x0C,0x03,0x00,0xC0,0x30,0x0C,0x03,0x00,0xC0,0x30,0xFF,0xFF,0xF0, // '2' 0x32,0x01,0x0C,0x12,0x02,0x0F, 0x3F,0x0F,0xF8,0xC1,0xC0,0x0E,0x00,0x60,0x06,0x00,0x60,0x0C,0x01,0xC0,0x18,0x03,0x00,0x60,0x0C,0x01,0x80,0x30,0x06,0x00,0xFF,0xEF,0xFE, // '3' 0x33,0x01,0x0C,0x12,0x02,0x0F, 0x3F,0x07,0xFC,0x41,0xC0,0x06,0x00,0x60,0x06,0x00,0x60,0x0C,0x1F,0x81,0xFC,0x00,0xE0,0x07,0x00,0x30,0x03,0x00,0x78,0x0E,0xFF,0xC3,0xF0, // '4' 0x34,0x01,0x0D,0x12,0x01,0x0F, 0x01,0xC0,0x1E,0x00,0xB0,0x0D,0x80,0xCC,0x06,0x60,0x63,0x03,0x18,0x30,0xC3,0x06,0x18,0x31,0x81,0x8F,0xFF,0xFF,0xFC,0x03,0x00,0x18,0x00,0xC0,0x06,0x00, // '5' 0x35,0x01,0x0B,0x12,0x02,0x0F, 0x7F,0xCF,0xF9,0x80,0x30,0x06,0x00,0xC0,0x1F,0xC3,0xFC,0x41,0xC0,0x1C,0x01,0x80,0x30,0x06,0x00,0xC0,0x3C,0x0E,0xFF,0x8F,0xC0, // '6' 0x36,0x01,0x0C,0x12,0x02,0x0F, 0x07,0xC1,0xFE,0x38,0x27,0x00,0x60,0x0C,0x00,0xCF,0x8D,0xFC,0xF8,0xEF,0x07,0xE0,0x3E,0x03,0xE0,0x36,0x03,0x70,0x77,0x8E,0x3F,0xC0,0xF8, // '7' 0x37,0x01,0x0B,0x12,0x02,0x0F, 0xFF,0xFF,0xFC,0x03,0x00,0x60,0x1C,0x03,0x00,0x60,0x18,0x03,0x00,0xE0,0x18,0x03,0x00,0xC0,0x18,0x07,0x00,0xC0,0x18,0x06,0x00, // '8' 0x38,0x01,0x0C,0x12,0x02,0x0F, 0x1F,0x87,0xFE,0x70,0xEC,0x03,0xC0,0x3C,0x03,0xC0,0x37,0x0E,0x3F,0xC3,0xFC,0x70,0xEC,0x03,0xC0,0x3C,0x03,0xC0,0x37,0x0E,0x7F,0xE1,0xF8, // '9' 0x39,0x01,0x0C,0x12,0x02,0x0F, 0x1F,0x03,0xFC,0x71,0xCE,0x0E,0xC0,0x6C,0x07,0xC0,0x7C,0x07,0xE0,0xF7,0x1F,0x3F,0xB1,0xF3,0x00,0x30,0x06,0x00,0xE4,0x1C,0x7F,0x83,0xE0, // ':' 0x3A,0x07,0x02,0x0C,0x03,0x08, 0xFC,0x00,0x3F, // ';' 0x3B,0x07,0x03,0x0F,0x02,0x08, 0x6D,0x80,0x00,0x0D,0xB7,0xB0, // '<' 0x3C,0x05,0x0F,0x0D,0x03,0x14, 0x00,0x02,0x00,0x3C,0x03,0xF0,0x3F,0x01,0xF8,0x1F,0x80,0x3C,0x00,0x7E,0x00,0x1F,0x80,0x0F,0xC0,0x03,0xF0,0x00,0xF0,0x00,0x20, // '=' 0x3D,0x08,0x0F,0x07,0x03,0x14, 0xFF,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xFF,0xFF,0x80, // '>' 0x3E,0x05,0x0F,0x0D,0x03,0x14, 0x80,0x01,0xE0,0x01,0xF8,0x00,0x7E,0x00,0x3F,0x00,0x0F,0xC0,0x07,0x80,0x3F,0x03,0xF0,0x1F,0x81,0xF8,0x07,0x80,0x08,0x00,0x00, // '?' 0x3F,0x01,0x09,0x12,0x02,0x0D, 0x3E,0x3F,0xB0,0xF0,0x30,0x18,0x0C,0x0C,0x0E,0x0E,0x0E,0x06,0x03,0x01,0x80,0x00,0x00,0x30,0x18,0x0C,0x00, // '@' 0x40,0x02,0x15,0x15,0x02,0x18, 0x00,0xFC,0x00,0x3F,0xF8,0x03,0xC0,0xF0,0x38,0x01,0xC3,0x80,0x07,0x38,0x79,0x99,0x8F,0xEC,0xFC,0x71,0xE3,0xC7,0x07,0x1E,0x30,0x18,0xF1,0x80,0xC7,0x8C,0x06,0x3C,0x70,0x73,0x71,0xC7,0xB9,0x8F,0xEF,0x8E,0x1E,0x70,0x38,0x00,0x00,0xE0,0x04,0x03,0xC0,0xE0,0x0F,0xFE,0x00,0x0F,0x80,0x00, // 'A' 0x41,0x01,0x10,0x12,0x00,0x10, 0x03,0xC0,0x03,0xC0,0x03,0xC0,0x07,0xE0,0x06,0x60,0x06,0x60,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x18,0x18,0x18,0x18,0x38,0x1C,0x3F,0xFC,0x3F,0xFC,0x60,0x06,0x60,0x06,0x60,0x06,0xC0,0x03, // 'B' 0x42,0x01,0x0C,0x12,0x02,0x10, 0xFF,0x0F,0xFC,0xC0,0xEC,0x06,0xC0,0x6C,0x06,0xC0,0x6C,0x0C,0xFF,0x8F,0xFC,0xC0,0x6C,0x03,0xC0,0x3C,0x03,0xC0,0x3C,0x06,0xFF,0xEF,0xF8, // 'C' 0x43,0x01,0x0E,0x12,0x01,0x11, 0x07,0xE0,0x7F,0xE3,0xC1,0xDC,0x01,0x60,0x01,0x80,0x0C,0x00,0x30,0x00,0xC0,0x03,0x00,0x0C,0x00,0x30,0x00,0x60,0x01,0x80,0x07,0x00,0x4F,0x07,0x1F,0xF8,0x1F,0x80, // 'D' 0x44,0x01,0x0F,0x12,0x02,0x12, 0xFF,0x81,0xFF,0xE3,0x01,0xE6,0x00,0xEC,0x00,0xD8,0x01,0xF0,0x01,0xE0,0x03,0xC0,0x07,0x80,0x0F,0x00,0x1E,0x00,0x3C,0x00,0xF8,0x01,0xB0,0x07,0x60,0x3C,0xFF,0xF1,0xFF,0x00, // 'E' 0x45,0x01,0x0B,0x12,0x02,0x0F, 0xFF,0xFF,0xFF,0x00,0x60,0x0C,0x01,0x80,0x30,0x06,0x00,0xFF,0xDF,0xFB,0x00,0x60,0x0C,0x01,0x80,0x30,0x06,0x00,0xFF,0xFF,0xFC, // 'F' 0x46,0x01,0x0A,0x12,0x02,0x0E, 0xFF,0xFF,0xFC,0x03,0x00,0xC0,0x30,0x0C,0x03,0x00,0xFF,0xBF,0xEC,0x03,0x00,0xC0,0x30,0x0C,0x03,0x00,0xC0,0x30,0x00, // 'G' 0x47,0x01,0x0F,0x12,0x01,0x13, 0x07,0xE0,0x3F,0xF0,0xE0,0x73,0x80,0x26,0x00,0x1C,0x00,0x30,0x00,0x60,0x00,0xC0,0x7F,0x80,0xFF,0x00,0x1E,0x00,0x36,0x00,0x6C,0x00,0xDC,0x01,0x9E,0x07,0x1F,0xFC,0x0F,0xE0, // 'H' 0x48,0x01,0x0D,0x12,0x02,0x12, 0xC0,0x1E,0x00,0xF0,0x07,0x80,0x3C,0x01,0xE0,0x0F,0x00,0x78,0x03,0xFF,0xFF,0xFF,0xF0,0x07,0x80,0x3C,0x01,0xE0,0x0F,0x00,0x78,0x03,0xC0,0x1E,0x00,0xC0, // 'I' 0x49,0x01,0x02,0x12,0x02,0x07, 0xFF,0xFF,0xFF,0xFF,0xF0, // 'J' 0x4A,0x01,0x06,0x17,0xFE,0x07, 0x0C,0x30,0xC3,0x0C,0x30,0xC3,0x0C,0x30,0xC3,0x0C,0x30,0xC3,0x0C,0x30,0xC3,0x1B,0xEF,0x00, // 'K' 0x4B,0x01,0x0F,0x12,0x02,0x10, 0xC0,0x71,0x81,0xC3,0x07,0x06,0x1C,0x0C,0x70,0x19,0xC0,0x37,0x00,0x7C,0x00,0xF8,0x01,0xB0,0x03,0x38,0x06,0x38,0x0C,0x38,0x18,0x38,0x30,0x38,0x60,0x38,0xC0,0x39,0x80,0x38, // 'L' 0x4C,0x01,0x0B,0x12,0x02,0x0D, 0xC0,0x18,0x03,0x00,0x60,0x0C,0x01,0x80,0x30,0x06,0x00,0xC0,0x18,0x03,0x00,0x60,0x0C,0x01,0x80,0x30,0x06,0x00,0xFF,0xFF,0xFC, // 'M' 0x4D,0x01,0x10,0x12,0x02,0x15, 0xE0,0x07,0xF0,0x0F,0xF0,0x0F,0xF8,0x1F,0xD8,0x1B,0xD8,0x1B,0xCC,0x33,0xCC,0x33,0xCC,0x33,0xC6,0x63,0xC6,0x63,0xC7,0xE3,0xC3,0xC3,0xC3,0xC3,0xC1,0x83,0xC0,0x03,0xC0,0x03,0xC0,0x03, // 'N' 0x4E,0x01,0x0D,0x12,0x02,0x12, 0xE0,0x1F,0x80,0xFC,0x07,0xF0,0x3D,0x81,0xE6,0x0F,0x30,0x78,0xC3,0xC6,0x1E,0x18,0xF0,0xC7,0x83,0x3C,0x19,0xE0,0x6F,0x03,0x78,0x0F,0xC0,0x7E,0x01,0xC0, // 'O' 0x4F,0x01,0x10,0x12,0x01,0x13, 0x07,0xE0,0x1F,0xF8,0x3C,0x3C,0x70,0x0E,0x60,0x06,0x60,0x06,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0x60,0x06,0x60,0x06,0x70,0x0E,0x3C,0x3C,0x1F,0xF8,0x07,0xE0, // 'P' 0x50,0x01,0x0B,0x12,0x02,0x0E, 0xFF,0x1F,0xFB,0x07,0x60,0x3C,0x07,0x80,0xF0,0x1E,0x0E,0xFF,0xDF,0xE3,0x00,0x60,0x0C,0x01,0x80,0x30,0x06,0x00,0xC0,0x18,0x00, // 'Q' 0x51,0x01,0x10,0x15,0x01,0x13, 0x07,0xE0,0x1F,0xF8,0x3C,0x3C,0x70,0x0E,0x60,0x06,0x60,0x06,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0x60,0x07,0x60,0x06,0x70,0x0E,0x3C,0x3C,0x1F,0xF8,0x07,0xF0,0x00,0x38,0x00,0x18,0x00,0x0C, // 'R' 0x52,0x01,0x0D,0x12,0x02,0x11, 0xFF,0x07,0xFE,0x30,0x31,0x80,0xCC,0x06,0x60,0x33,0x01,0x98,0x18,0xFF,0xC7,0xFC,0x30,0x71,0x81,0x8C,0x06,0x60,0x33,0x01,0xD8,0x06,0xC0,0x36,0x00,0xC0, // 'S' 0x53,0x01,0x0C,0x12,0x02,0x0F, 0x1F,0x87,0xFE,0x70,0x6C,0x00,0xC0,0x0C,0x00,0xC0,0x07,0x00,0x7F,0x01,0xFC,0x00,0xE0,0x07,0x00,0x30,0x03,0x00,0x3C,0x0E,0xFF,0xE3,0xF8, // 'T' 0x54,0x01,0x0E,0x12,0x00,0x0F, 0xFF,0xFF,0xFF,0xF0,0x30,0x00,0xC0,0x03,0x00,0x0C,0x00,0x30,0x00,0xC0,0x03,0x00,0x0C,0x00,0x30,0x00,0xC0,0x03,0x00,0x0C,0x00,0x30,0x00,0xC0,0x03,0x00,0x0C,0x00, // 'U' 0x55,0x01,0x0D,0x12,0x02,0x12, 0xC0,0x1E,0x00,0xF0,0x07,0x80,0x3C,0x01,0xE0,0x0F,0x00,0x78,0x03,0xC0,0x1E,0x00,0xF0,0x07,0x80,0x3C,0x01,0xE0,0x0D,0x80,0xCE,0x0E,0x3F,0xE0,0x7C,0x00, // 'V' 0x56,0x01,0x10,0x12,0x00,0x10, 0xC0,0x03,0x60,0x06,0x60,0x06,0x60,0x06,0x30,0x0C,0x30,0x0C,0x38,0x1C,0x18,0x18,0x18,0x18,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x06,0x60,0x06,0x60,0x07,0x60,0x03,0xC0,0x03,0xC0,0x03,0xC0, // 'W' 0x57,0x01,0x16,0x12,0x01,0x18, 0xC0,0x78,0x0F,0x01,0xE0,0x36,0x07,0x81,0x98,0x1E,0x06,0x60,0xEC,0x19,0x83,0x30,0x63,0x0C,0xC3,0x0C,0x33,0x0C,0x30,0xCE,0x30,0xC6,0x18,0xC1,0x98,0x66,0x06,0x61,0x98,0x19,0x86,0x60,0x6C,0x0D,0x80,0xF0,0x3C,0x03,0xC0,0xF0,0x0F,0x03,0xC0,0x38,0x07,0x00, // 'X' 0x58,0x01,0x0F,0x12,0x01,0x11, 0x70,0x0E,0x60,0x18,0x60,0x60,0xE1,0xC0,0xC7,0x00,0xCC,0x01,0xF0,0x01,0xE0,0x03,0x80,0x07,0x80,0x1F,0x00,0x37,0x00,0xC6,0x03,0x86,0x0E,0x0E,0x18,0x0C,0x60,0x0D,0xC0,0x1C, // 'Y' 0x59,0x01,0x0E,0x12,0x00,0x0F, 0xE0,0x1D,0x80,0x63,0x03,0x0E,0x1C,0x18,0x60,0x33,0x00,0xFC,0x01,0xE0,0x07,0x80,0x0C,0x00,0x30,0x00,0xC0,0x03,0x00,0x0C,0x00,0x30,0x00,0xC0,0x03,0x00,0x0C,0x00, // 'Z' 0x5A,0x01,0x0E,0x12,0x01,0x10, 0xFF,0xFF,0xFF,0xF0,0x01,0x80,0x0E,0x00,0x70,0x01,0x80,0x0C,0x00,0x60,0x03,0x80,0x1C,0x00,0x60,0x03,0x00,0x18,0x00,0xE0,0x07,0x00,0x18,0x00,0xFF,0xFF,0xFF,0xF0, // '[' 0x5B,0x01,0x05,0x15,0x02,0x09, 0xFF,0xF1,0x8C,0x63,0x18,0xC6,0x31,0x8C,0x63,0x18,0xC6,0x31,0xFF,0x80, // '\' 0x5C,0x01,0x08,0x14,0x00,0x08, 0xC0,0xE0,0x60,0x60,0x60,0x30,0x30,0x30,0x18,0x18,0x18,0x18,0x0C,0x0C,0x0C,0x06,0x06,0x06,0x07,0x03, // ']' 0x5D,0x01,0x05,0x15,0x02,0x09, 0xFF,0xC6,0x31,0x8C,0x63,0x18,0xC6,0x31,0x8C,0x63,0x18,0xC7,0xFF,0x80, // '^' 0x5E,0x01,0x0F,0x07,0x03,0x14, 0x03,0x80,0x0F,0x80,0x3B,0x80,0xE3,0x83,0x83,0x8E,0x03,0xB8,0x03,0x80, // '_' 0x5F,0x17,0x0C,0x02,0x00,0x0C, 0xFF,0xFF,0xFF, // '`' 0x60,0x00,0x06,0x04,0x02,0x0C, 0x60,0xC1,0x83, // 'a' 0x61,0x06,0x0B,0x0D,0x01,0x0E, 0x3F,0x0F,0xF9,0x03,0x00,0x30,0x06,0x3F,0xDF,0xFF,0x03,0xC0,0x78,0x1F,0x87,0xBF,0xF3,0xE6, // 'b' 0x62,0x01,0x0C,0x12,0x02,0x0F, 0xC0,0x0C,0x00,0xC0,0x0C,0x00,0xC0,0x0C,0xF8,0xFF,0xCF,0x0E,0xE0,0x6C,0x03,0xC0,0x3C,0x03,0xC0,0x3C,0x03,0xE0,0x6F,0x0E,0xFF,0xCC,0xF8, // 'c' 0x63,0x06,0x0A,0x0D,0x01,0x0D, 0x0F,0x8F,0xF7,0x05,0x80,0xC0,0x30,0x0C,0x03,0x00,0xC0,0x18,0x07,0x04,0xFF,0x0F,0x80, // 'd' 0x64,0x01,0x0C,0x12,0x01,0x0F, 0x00,0x30,0x03,0x00,0x30,0x03,0x00,0x31,0xF3,0x3F,0xF7,0x0F,0x60,0x7C,0x03,0xC0,0x3C,0x03,0xC0,0x3C,0x03,0x60,0x77,0x0F,0x3F,0xF1,0xF3, // 'e' 0x65,0x06,0x0C,0x0D,0x01,0x0E, 0x0F,0x83,0xFC,0x70,0xE6,0x07,0xC0,0x3F,0xFF,0xFF,0xFC,0x00,0xC0,0x06,0x00,0x70,0x23,0xFE,0x0F,0xC0, // 'f' 0x66,0x01,0x08,0x12,0x01,0x08, 0x0F,0x1F,0x38,0x30,0x30,0xFF,0xFF,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30, // 'g' 0x67,0x06,0x0C,0x12,0x01,0x0F, 0x1F,0x33,0xFF,0x70,0xF6,0x07,0xC0,0x3C,0x03,0xC0,0x3C,0x03,0xC0,0x36,0x07,0x70,0xF3,0xFF,0x1F,0x30,0x03,0x00,0x72,0x0E,0x3F,0xC1,0xF8, // 'h' 0x68,0x01,0x0B,0x12,0x02,0x0F, 0xC0,0x18,0x03,0x00,0x60,0x0C,0x01,0x9F,0x3F,0xF7,0x87,0xE0,0x78,0x0F,0x01,0xE0,0x3C,0x07,0x80,0xF0,0x1E,0x03,0xC0,0x78,0x0C, // 'i' 0x69,0x01,0x02,0x12,0x02,0x07, 0xFC,0x3F,0xFF,0xFF,0xF0, // 'j' 0x6A,0x01,0x05,0x17,0xFF,0x07, 0x18,0xC6,0x00,0x0C,0x63,0x18,0xC6,0x31,0x8C,0x63,0x18,0xC6,0x33,0xFB,0x80, // 'k' 0x6B,0x01,0x0C,0x12,0x02,0x0E, 0xC0,0x0C,0x00,0xC0,0x0C,0x00,0xC0,0x0C,0x1C,0xC3,0x8C,0x70,0xCE,0x0D,0xC0,0xF8,0x0F,0x80,0xDC,0x0C,0xE0,0xC7,0x0C,0x38,0xC1,0xCC,0x0E, // 'l' 0x6C,0x01,0x02,0x12,0x02,0x06, 0xFF,0xFF,0xFF,0xFF,0xF0, // 'm' 0x6D,0x06,0x14,0x0D,0x02,0x18, 0xCF,0x87,0xCF,0xFC,0xFE,0xF0,0xF8,0x7E,0x07,0x03,0xC0,0x60,0x3C,0x06,0x03,0xC0,0x60,0x3C,0x06,0x03,0xC0,0x60,0x3C,0x06,0x03,0xC0,0x60,0x3C,0x06,0x03,0xC0,0x60,0x30, // 'n' 0x6E,0x06,0x0B,0x0D,0x02,0x0F, 0xCF,0x9F,0xFB,0xC3,0xF0,0x3C,0x07,0x80,0xF0,0x1E,0x03,0xC0,0x78,0x0F,0x01,0xE0,0x3C,0x06, // 'o' 0x6F,0x06,0x0C,0x0D,0x01,0x0E, 0x1F,0x83,0xFC,0x70,0xE6,0x06,0xC0,0x3C,0x03,0xC0,0x3C,0x03,0xC0,0x36,0x06,0x70,0xE3,0xFC,0x1F,0x80, // 'p' 0x70,0x06,0x0C,0x12,0x02,0x0F, 0xCF,0x8F,0xFC,0xF0,0xEE,0x06,0xC0,0x3C,0x03,0xC0,0x3C,0x03,0xC0,0x3E,0x06,0xF0,0xEF,0xFC,0xCF,0x8C,0x00,0xC0,0x0C,0x00,0xC0,0x0C,0x00, // 'q' 0x71,0x06,0x0C,0x12,0x01,0x0F, 0x1F,0x33,0xFF,0x70,0xF6,0x07,0xC0,0x3C,0x03,0xC0,0x3C,0x03,0xC0,0x36,0x07,0x70,0xF3,0xFF,0x1F,0x30,0x03,0x00,0x30,0x03,0x00,0x30,0x03, // 'r' 0x72,0x06,0x08,0x0D,0x02,0x0A, 0xCF,0xFF,0xF0,0xE0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0, // 's' 0x73,0x06,0x0B,0x0D,0x01,0x0C, 0x3F,0x0F,0xF3,0x82,0x60,0x0C,0x00,0xF0,0x0F,0xC0,0x3C,0x00,0xC0,0x1A,0x07,0x7F,0xC7,0xF0, // 't' 0x74,0x02,0x08,0x11,0x00,0x09, 0x30,0x30,0x30,0x30,0xFF,0xFF,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x1F,0x0F, // 'u' 0x75,0x06,0x0B,0x0D,0x02,0x0F, 0xC0,0x78,0x0F,0x01,0xE0,0x3C,0x07,0x80,0xF0,0x1E,0x03,0xC0,0x78,0x1F,0x87,0xBF,0xF3,0xE6, // 'v' 0x76,0x06,0x0D,0x0D,0x01,0x0F, 0xC0,0x1B,0x01,0x98,0x0C,0xC0,0x63,0x06,0x18,0x30,0x63,0x03,0x18,0x18,0xC0,0x6C,0x03,0x60,0x1F,0x00,0x70,0x00, // 'w' 0x77,0x06,0x12,0x0D,0x01,0x14, 0xC1,0xE0,0xF0,0x78,0x36,0x1E,0x19,0x87,0x86,0x63,0x31,0x9C,0xCC,0xE3,0x33,0x30,0xCC,0xCC,0x36,0x1B,0x07,0x87,0x81,0xE1,0xE0,0x78,0x78,0x1C,0x0E,0x00, // 'x' 0x78,0x06,0x0D,0x0D,0x01,0x0F, 0xE0,0x3B,0x83,0x8E,0x38,0x31,0x80,0xD8,0x07,0xC0,0x1C,0x01,0xF0,0x1D,0xC0,0xC6,0x0C,0x18,0xE0,0xEE,0x03,0x80, // 'y' 0x79,0x06,0x0D,0x12,0x01,0x0F, 0xC0,0x1B,0x01,0x98,0x0C,0xE0,0xE3,0x06,0x18,0x70,0x63,0x03,0x18,0x0D,0x80,0x6C,0x03,0xE0,0x0E,0x00,0x70,0x03,0x00,0x18,0x01,0x80,0x7C,0x03,0xC0,0x00, // 'z' 0x7A,0x06,0x0B,0x0D,0x01,0x0D, 0xFF,0xFF,0xFC,0x03,0x00,0xE0,0x38,0x0E,0x03,0x80,0xE0,0x38,0x0E,0x01,0x80,0x7F,0xFF,0xFE, // '{' 0x7B,0x01,0x09,0x16,0x03,0x0F, 0x03,0x83,0xC3,0x81,0x80,0xC0,0x60,0x30,0x18,0x0C,0x0E,0x3E,0x1F,0x01,0xC0,0x60,0x30,0x18,0x0C,0x06,0x03,0x01,0xC0,0x78,0x1C, // '|' 0x7C,0x01,0x02,0x18,0x03,0x08, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, // '}' 0x7D,0x01,0x09,0x16,0x03,0x0F, 0xE0,0x78,0x0E,0x03,0x01,0x80,0xC0,0x60,0x30,0x18,0x0E,0x03,0xE1,0xF1,0xC0,0xC0,0x60,0x30,0x18,0x0C,0x06,0x07,0x0F,0x07,0x00, // '~' 0x7E,0x09,0x0F,0x05,0x03,0x14, 0x00,0x00,0x7C,0x05,0xFE,0x1E,0x1F,0xE0,0x0F,0x80, // Terminator 0xFF };
YifuLiu/AliOS-Things
components/py_engine/modules/display/esp32/tft/font/DejaVuSans24.c
C
apache-2.0
15,937
/* * This file is part of the MicroPython ESP32 project, https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo * * The MIT License (MIT) * * Copyright (c) 2018 LoBo (https://github.com/loboris) * */ /* * This is the source file for the Proportional font * used in Display.TFT module on LoBo MicroPython * The data bits are packed to minimize data requirements, * but the tradeoff is that a header is required per character. * This file can be compiled on MicroPython using the tft.compileFont() method, * or included into build to be compiled into MicroPython firmware * TTF File name: DejaVuSans.ttf * Code page : ascii * Point Size : 40 * Memory usage : 6269 bytes * # characters : 96 * Header Format (4 bytes): * ------------------------ * Character Width always 0 to indicate the proportional font format * Character Height character height in pixels * First Character always 0, not used * Number Of Characters always 0, not used * Any number of character blocks can follow * Individual Character Format (6 bytes): * -------------------------------------- * Character Code character code in selected code page * Adjusted Y Offset offset to the 1st visible row * Width visible with of the character * Height visible height of the character * xOffset X offset in visible character area * xDelta the distance to move the cursor. Effective width of the character. * Data[n] packed character data * NOTE: You can remove any of these characters if they are not needed in your application. * The first character number in each Glyph indicates the CODE PAGE character code. * Therefore, these do not have to be sequential. * Just remove all the content for a particular character to save space. */ #include "sdkconfig.h" const unsigned char tft_Dejavu40[] = { // Header 0x00, 0x28, 0x00, 0x00, // Character data //' ' size: 6+0 0x20,0x1F,0x00,0x00,0x06,0x0C, //'!' size: 6+14 0x21,0x03,0x04,0x1C,0x06,0x10, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x00,0x0F,0xFF,0xFF, //'"' size: 6+14 0x22,0x03,0x0A,0x0B,0x04,0x12, 0xE1,0xF8,0x7E,0x1F,0x87,0xE1,0xF8,0x7E,0x1F,0x87,0xE1,0xF8,0x7E,0x1C, //'#' size: 6+95 0x23,0x03,0x1B,0x1C,0x03,0x21, 0x00,0x1C,0x0E,0x00,0x03,0x83,0xC0,0x00,0xF0,0x70,0x00,0x1C,0x0E,0x00,0x03,0x81, 0xC0,0x00,0x70,0x78,0x00,0x0E,0x0E,0x00,0x03,0x81,0xC0,0x3F,0xFF,0xFF,0xE7, 0xFF,0xFF,0xFC,0xFF,0xFF,0xFF,0x80,0x70,0x38,0x00,0x0E,0x07,0x00,0x01,0xC1, 0xE0,0x00,0x78,0x38,0x00,0x0E,0x07,0x00,0x01,0xC0,0xE0,0x1F,0xFF,0xFF,0xF3, 0xFF,0xFF,0xFE,0x7F,0xFF,0xFF,0xC0,0x38,0x1C,0x00,0x07,0x07,0x80,0x01,0xE0, 0xE0,0x00,0x38,0x1C,0x00,0x07,0x03,0x80,0x00,0xE0,0xF0,0x00,0x3C,0x1C,0x00, 0x07,0x03,0x80,0x00, //'$' size: 6+79 0x24,0x02,0x12,0x23,0x04,0x19, 0x00,0xC0,0x00,0x30,0x00,0x0C,0x00,0x03,0x00,0x07,0xFC,0x07,0xFF,0xC3,0xFF,0xF1, 0xF3,0x0C,0xF8,0xC0,0x3C,0x30,0x0F,0x0C,0x03,0xC3,0x00,0xF8,0xC0,0x1F,0xF0, 0x07,0xFF,0x00,0xFF,0xF8,0x0F,0xFF,0x00,0x3F,0xE0,0x0C,0xF8,0x03,0x1F,0x00, 0xC3,0xC0,0x30,0xF0,0x0C,0x3C,0x03,0x0F,0x80,0xC7,0xFC,0x33,0xEF,0xFF,0xF1, 0xFF,0xF8,0x0F,0xF8,0x00,0x30,0x00,0x0C,0x00,0x03,0x00,0x00,0xC0,0x00,0x30, 0x00,0x0C,0x00, //'%' size: 6+120 0x25,0x02,0x21,0x1D,0x02,0x25, 0x0F,0x80,0x01,0xE0,0x1F,0xF0,0x00,0xE0,0x1E,0x3C,0x00,0xF0,0x0E,0x0E,0x00,0xF0, 0x0E,0x03,0x80,0x70,0x07,0x01,0xC0,0x78,0x03,0x80,0xE0,0x38,0x01,0xC0,0x70, 0x3C,0x00,0xE0,0x38,0x3C,0x00,0x70,0x1C,0x1C,0x00,0x38,0x0E,0x1E,0x00,0x0E, 0x0E,0x0E,0x00,0x07,0x8F,0x0E,0x00,0x01,0xFF,0x0F,0x00,0x00,0x3E,0x07,0x03, 0xE0,0x00,0x07,0x87,0xFC,0x00,0x03,0x87,0x8F,0x00,0x03,0x83,0x83,0x80,0x03, 0xC3,0x80,0xE0,0x01,0xC1,0xC0,0x70,0x01,0xE0,0xE0,0x38,0x01,0xE0,0x70,0x1C, 0x00,0xE0,0x38,0x0E,0x00,0xF0,0x1C,0x07,0x00,0x70,0x0E,0x03,0x80,0x78,0x03, 0x83,0x80,0x78,0x01,0xE3,0xC0,0x38,0x00,0x7F,0xC0,0x3C,0x00,0x0F,0x80, //'&' size: 6+98 0x26,0x02,0x1B,0x1D,0x02,0x1E, 0x01,0xFC,0x00,0x00,0x7F,0xE0,0x00,0x1F,0xFE,0x00,0x07,0xC1,0xC0,0x01,0xF0,0x08, 0x00,0x3C,0x00,0x00,0x07,0x80,0x00,0x00,0xF0,0x00,0x00,0x1E,0x00,0x00,0x03, 0xE0,0x00,0x00,0x7E,0x00,0x00,0x07,0xC0,0x00,0x00,0xFC,0x00,0x00,0x3F,0xC0, 0x00,0x0F,0x7C,0x00,0xF3,0xC7,0xC0,0x1E,0x78,0x7C,0x03,0x9E,0x07,0xC0,0xF3, 0xC0,0x7C,0x1E,0x78,0x07,0xC3,0x8F,0x00,0x7C,0xF1,0xE0,0x07,0xFC,0x3E,0x00, 0x7F,0x03,0xC0,0x07,0xE0,0x7C,0x01,0xFE,0x07,0xE0,0xFF,0xE0,0x7F,0xFE,0x7E, 0x07,0xFF,0x87,0xE0,0x1F,0xC0,0x7E, //''' size: 6+5 0x27,0x03,0x03,0x0B,0x04,0x0B, 0xFF,0xFF,0xFF,0xFF,0x80, //'(' size: 6+40 0x28,0x01,0x09,0x23,0x03,0x0F, 0x03,0x83,0x83,0xC1,0xC1,0xE0,0xE0,0xF0,0x78,0x38,0x3C,0x1E,0x0F,0x0F,0x07,0x83, 0xC1,0xE0,0xF0,0x78,0x3C,0x1E,0x0F,0x07,0x83,0xC0,0xF0,0x78,0x3C,0x0E,0x07, 0x83,0xC0,0xE0,0x78,0x1C,0x0F,0x03,0x80,0xE0, //')' size: 6+40 0x29,0x01,0x09,0x23,0x03,0x0F, 0xE0,0x38,0x1E,0x07,0x03,0xC0,0xE0,0x78,0x3C,0x0E,0x07,0x83,0xC1,0xE0,0x70,0x3C, 0x1E,0x0F,0x07,0x83,0xC1,0xE0,0xF0,0x78,0x3C,0x1E,0x1E,0x0F,0x07,0x83,0x83, 0xC1,0xE0,0xE0,0xF0,0x70,0x78,0x38,0x38,0x00, //'*' size: 6+36 0x2A,0x02,0x10,0x12,0x02,0x14, 0x01,0x80,0x01,0x80,0x01,0x80,0x41,0x82,0xE1,0x87,0x79,0x9E,0x3D,0xBC,0x0F,0xF0, 0x03,0xC0,0x03,0xC0,0x0F,0xF0,0x3D,0xBC,0x79,0x9E,0xE1,0x87,0x41,0x82,0x01, 0x80,0x01,0x80,0x01,0x80, //'+' size: 6+79 0x2B,0x06,0x19,0x19,0x04,0x21, 0x00,0x1C,0x00,0x00,0x0E,0x00,0x00,0x07,0x00,0x00,0x03,0x80,0x00,0x01,0xC0,0x00, 0x00,0xE0,0x00,0x00,0x70,0x00,0x00,0x38,0x00,0x00,0x1C,0x00,0x00,0x0E,0x00, 0x00,0x07,0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,0x70, 0x00,0x00,0x38,0x00,0x00,0x1C,0x00,0x00,0x0E,0x00,0x00,0x07,0x00,0x00,0x03, 0x80,0x00,0x01,0xC0,0x00,0x00,0xE0,0x00,0x00,0x70,0x00,0x00,0x38,0x00,0x00, 0x1C,0x00,0x00, //',' size: 6+7 0x2C,0x1A,0x06,0x09,0x03,0x0C, 0x3C,0xF3,0xCF,0x39,0xC7,0x38,0xC0, //'-' size: 6+4 0x2D,0x13,0x0A,0x03,0x02,0x0E, 0xFF,0xFF,0xFF,0xFC, //'.' size: 6+3 0x2E,0x1A,0x04,0x05,0x04,0x0C, 0xFF,0xFF,0xF0, //'/' size: 6+52 0x2F,0x03,0x0D,0x20,0x00,0x0D, 0x00,0x38,0x03,0xC0,0x1C,0x00,0xE0,0x0F,0x00,0x70,0x03,0x80,0x1C,0x01,0xC0,0x0E, 0x00,0x70,0x07,0x00,0x38,0x01,0xC0,0x1E,0x00,0xE0,0x07,0x00,0x78,0x03,0x80, 0x1C,0x00,0xE0,0x0E,0x00,0x70,0x03,0x80,0x38,0x01,0xC0,0x0E,0x00,0xF0,0x07, 0x00,0x38,0x03,0xC0,0x1C,0x00, //'0' size: 6+73 0x30,0x02,0x14,0x1D,0x03,0x19, 0x01,0xF8,0x00,0x7F,0xE0,0x0F,0xFF,0x01,0xF0,0xF8,0x3C,0x03,0xC3,0xC0,0x3C,0x78, 0x01,0xE7,0x80,0x1E,0x78,0x01,0xEF,0x00,0x0F,0xF0,0x00,0xFF,0x00,0x0F,0xF0, 0x00,0xFF,0x00,0x0F,0xF0,0x00,0xFF,0x00,0x0F,0xF0,0x00,0xFF,0x00,0x0F,0xF0, 0x00,0xFF,0x00,0x0F,0x78,0x01,0xE7,0x80,0x1E,0x78,0x01,0xE3,0xC0,0x3C,0x3C, 0x03,0xC1,0xF0,0xF8,0x0F,0xFF,0x00,0x7F,0xE0,0x01,0xF8,0x00, //'1' size: 6+60 0x31,0x03,0x11,0x1C,0x04,0x19, 0x0F,0xE0,0x7F,0xF0,0x3F,0xF8,0x1E,0x3C,0x00,0x1E,0x00,0x0F,0x00,0x07,0x80,0x03, 0xC0,0x01,0xE0,0x00,0xF0,0x00,0x78,0x00,0x3C,0x00,0x1E,0x00,0x0F,0x00,0x07, 0x80,0x03,0xC0,0x01,0xE0,0x00,0xF0,0x00,0x78,0x00,0x3C,0x00,0x1E,0x00,0x0F, 0x00,0x07,0x80,0x03,0xC0,0x01,0xE0,0x3F,0xFF,0xDF,0xFF,0xEF,0xFF,0xF0, //'2' size: 6+66 0x32,0x02,0x12,0x1D,0x04,0x19, 0x0F,0xF0,0x1F,0xFF,0x0F,0xFF,0xF3,0xE0,0x7E,0xE0,0x0F,0xA0,0x01,0xF0,0x00,0x3C, 0x00,0x0F,0x00,0x03,0xC0,0x00,0xF0,0x00,0x3C,0x00,0x1F,0x00,0x0F,0x80,0x03, 0xE0,0x01,0xF0,0x00,0xFC,0x00,0x7E,0x00,0x3F,0x00,0x1F,0x80,0x0F,0xC0,0x07, 0xE0,0x03,0xF0,0x01,0xF8,0x00,0xFC,0x00,0x7E,0x00,0x3F,0x00,0x0F,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xC0, //'3' size: 6+69 0x33,0x02,0x13,0x1D,0x03,0x19, 0x1F,0xF0,0x0F,0xFF,0xC1,0xFF,0xFC,0x30,0x0F,0xC0,0x00,0x78,0x00,0x07,0x80,0x00, 0xF0,0x00,0x1E,0x00,0x03,0xC0,0x00,0x78,0x00,0x1E,0x00,0x0F,0x80,0x7F,0xE0, 0x0F,0xF0,0x01,0xFF,0xC0,0x00,0xFC,0x00,0x07,0xC0,0x00,0x78,0x00,0x07,0x80, 0x00,0xF0,0x00,0x1E,0x00,0x03,0xC0,0x00,0x78,0x00,0x1E,0x80,0x07,0xDE,0x03, 0xF3,0xFF,0xFC,0x7F,0xFF,0x03,0xFF,0x00, //'4' size: 6+74 0x34,0x03,0x15,0x1C,0x02,0x19, 0x00,0x0F,0x80,0x00,0xFC,0x00,0x0F,0xE0,0x00,0x7F,0x00,0x07,0x78,0x00,0x7B,0xC0, 0x03,0x9E,0x00,0x38,0xF0,0x03,0xC7,0x80,0x3C,0x3C,0x01,0xC1,0xE0,0x1E,0x0F, 0x01,0xE0,0x78,0x0E,0x03,0xC0,0xE0,0x1E,0x0F,0x00,0xF0,0x70,0x07,0x87,0x00, 0x3C,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x03,0xC0,0x00,0x1E,0x00, 0x00,0xF0,0x00,0x07,0x80,0x00,0x3C,0x00,0x01,0xE0,0x00,0x0F,0x00, //'5' size: 6+63 0x35,0x03,0x12,0x1C,0x04,0x19, 0x7F,0xFF,0x1F,0xFF,0xC7,0xFF,0xF1,0xE0,0x00,0x78,0x00,0x1E,0x00,0x07,0x80,0x01, 0xE0,0x00,0x78,0x00,0x1F,0xFC,0x07,0xFF,0xC1,0xFF,0xF8,0x60,0x3F,0x00,0x03, 0xE0,0x00,0x78,0x00,0x1F,0x00,0x03,0xC0,0x00,0xF0,0x00,0x3C,0x00,0x0F,0x00, 0x03,0xC0,0x01,0xF0,0x00,0x7A,0x00,0x3E,0xE0,0x3F,0x3F,0xFF,0x8F,0xFF,0xC0, 0xFF,0x80, //'6' size: 6+73 0x36,0x02,0x14,0x1D,0x03,0x19, 0x00,0xFF,0x00,0x3F,0xFC,0x07,0xFF,0xC0,0xF8,0x1C,0x1E,0x00,0x43,0xC0,0x00,0x3C, 0x00,0x07,0x80,0x00,0x78,0x00,0x07,0x80,0x00,0xF0,0xFC,0x0F,0x3F,0xF0,0xF7, 0xFF,0x8F,0xF0,0x7C,0xFE,0x03,0xEF,0xC0,0x1E,0xF8,0x00,0xFF,0x80,0x0F,0xF8, 0x00,0xFF,0x80,0x0F,0x78,0x00,0xF7,0x80,0x0F,0x78,0x01,0xF3,0xC0,0x1E,0x3E, 0x03,0xE1,0xF0,0x7C,0x0F,0xFF,0x80,0x7F,0xF0,0x01,0xFC,0x00, //'7' size: 6+63 0x37,0x03,0x12,0x1C,0x04,0x19, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,0x1E,0x00,0x07,0x80,0x03,0xE0,0x00,0xF0, 0x00,0x3C,0x00,0x1E,0x00,0x07,0x80,0x03,0xE0,0x00,0xF0,0x00,0x3C,0x00,0x1F, 0x00,0x07,0x80,0x01,0xE0,0x00,0xF8,0x00,0x3C,0x00,0x1F,0x00,0x07,0x80,0x01, 0xE0,0x00,0xF8,0x00,0x3C,0x00,0x0F,0x00,0x07,0xC0,0x01,0xE0,0x00,0x78,0x00, 0x3C,0x00, //'8' size: 6+73 0x38,0x02,0x14,0x1D,0x03,0x19, 0x03,0xFC,0x00,0xFF,0xF0,0x1F,0xFF,0x83,0xE0,0x7C,0x7C,0x03,0xC7,0x80,0x1E,0x78, 0x01,0xE7,0x80,0x1E,0x78,0x01,0xE7,0x80,0x1E,0x3C,0x03,0xC1,0xE0,0x78,0x0F, 0xFF,0x00,0x3F,0xC0,0x1F,0xFF,0x83,0xE0,0x7C,0x7C,0x03,0xE7,0x80,0x1E,0xF0, 0x00,0xFF,0x00,0x0F,0xF0,0x00,0xFF,0x00,0x0F,0xF0,0x00,0xFF,0x80,0x1F,0x7C, 0x03,0xE7,0xE0,0x7E,0x3F,0xFF,0xC0,0xFF,0xF0,0x03,0xFC,0x00, //'9' size: 6+73 0x39,0x02,0x14,0x1D,0x03,0x19, 0x03,0xF8,0x00,0xFF,0xE0,0x1F,0xFF,0x03,0xE0,0xF8,0x7C,0x07,0xC7,0x80,0x3C,0xF0, 0x01,0xEF,0x00,0x1E,0xF0,0x01,0xEF,0x00,0x1F,0xF0,0x01,0xFF,0x00,0x1F,0xF0, 0x01,0xF7,0x80,0x3F,0x7C,0x07,0xF3,0xE0,0xFF,0x1F,0xFE,0xF0,0xFF,0xCF,0x03, 0xF0,0xF0,0x00,0x1E,0x00,0x01,0xE0,0x00,0x1E,0x00,0x03,0xC0,0x00,0x3C,0x20, 0x07,0x83,0x81,0xF0,0x3F,0xFE,0x03,0xFF,0xC0,0x0F,0xF0,0x00, //':' size: 6+10 0x3A,0x0B,0x04,0x14,0x05,0x0D, 0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00,0x0F,0xFF,0xFF, //';' size: 6+18 0x3B,0x0B,0x06,0x18,0x04,0x0D, 0x3C,0xF3,0xCF,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x3C,0xF3,0xCE,0x71, 0xCE,0x30, //'<' size: 6+63 0x3C,0x08,0x18,0x15,0x05,0x21, 0x00,0x00,0x01,0x00,0x00,0x0F,0x00,0x00,0x7F,0x00,0x01,0xFE,0x00,0x0F,0xF8,0x00, 0x7F,0xC0,0x03,0xFE,0x00,0x0F,0xF0,0x00,0x7F,0xC0,0x00,0xFE,0x00,0x00,0xF0, 0x00,0x00,0xFE,0x00,0x00,0x7F,0xC0,0x00,0x0F,0xF0,0x00,0x03,0xFE,0x00,0x00, 0x7F,0xC0,0x00,0x0F,0xF8,0x00,0x01,0xFE,0x00,0x00,0x7F,0x00,0x00,0x0F,0x00, 0x00,0x01, //'=' size: 6+33 0x3D,0x0D,0x18,0x0B,0x05,0x21, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF, //'>' size: 6+63 0x3E,0x08,0x18,0x15,0x05,0x21, 0x80,0x00,0x00,0xF0,0x00,0x00,0xFE,0x00,0x00,0x7F,0x80,0x00,0x1F,0xF0,0x00,0x03, 0xFE,0x00,0x00,0x7F,0xC0,0x00,0x0F,0xF0,0x00,0x03,0xFE,0x00,0x00,0x7F,0x00, 0x00,0x0F,0x00,0x00,0x7F,0x00,0x03,0xFE,0x00,0x0F,0xF0,0x00,0x7F,0xC0,0x03, 0xFE,0x00,0x1F,0xF0,0x00,0x7F,0x80,0x00,0xFE,0x00,0x00,0xF0,0x00,0x00,0x80, 0x00,0x00, //'?' size: 6+55 0x3F,0x02,0x0F,0x1D,0x03,0x15, 0x0F,0xE0,0xFF,0xE3,0xFF,0xE7,0x83,0xEC,0x03,0xF0,0x03,0xC0,0x07,0x80,0x0F,0x00, 0x1E,0x00,0x78,0x00,0xF0,0x03,0xC0,0x0F,0x00,0x3C,0x00,0xF0,0x03,0xC0,0x07, 0x80,0x0F,0x00,0x1E,0x00,0x3C,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x07, 0x80,0x0F,0x00,0x1E,0x00,0x3C,0x00,0x78,0x00, //'@' size: 6+145 0x40,0x04,0x22,0x22,0x03,0x27, 0x00,0x07,0xFC,0x00,0x00,0x0F,0xFF,0xE0,0x00,0x0F,0xFF,0xFE,0x00,0x07,0xF0,0x0F, 0xC0,0x07,0xE0,0x00,0xF8,0x03,0xE0,0x00,0x0F,0x00,0xF0,0x00,0x01,0xE0,0x78, 0x00,0x00,0x3C,0x3C,0x00,0x00,0x07,0x8E,0x01,0xF8,0xE0,0xE7,0x80,0xFF,0xB8, 0x39,0xC0,0x7F,0xFE,0x07,0x70,0x3E,0x1F,0x81,0xF8,0x0E,0x01,0xE0,0x7E,0x07, 0x80,0x78,0x1F,0x81,0xC0,0x0E,0x07,0xE0,0x70,0x03,0x81,0xF8,0x1C,0x00,0xE0, 0x7E,0x07,0x00,0x38,0x3B,0x81,0xC0,0x1E,0x1E,0xE0,0x38,0x07,0x87,0x1C,0x0F, 0x87,0xE7,0x87,0x01,0xFF,0xFF,0xC1,0xE0,0x3F,0xEF,0xE0,0x38,0x07,0xE3,0xC0, 0x0F,0x00,0x00,0x00,0x01,0xE0,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x0F,0x80, 0x00,0x20,0x01,0xF8,0x00,0x3C,0x00,0x3F,0x80,0x7E,0x00,0x03,0xFF,0xFF,0x00, 0x00,0x3F,0xFF,0x00,0x00,0x01,0xFE,0x00,0x00, //'A' size: 6+91 0x41,0x03,0x1A,0x1C,0x01,0x1B, 0x00,0x1E,0x00,0x00,0x0F,0xC0,0x00,0x03,0xF0,0x00,0x01,0xFE,0x00,0x00,0x7F,0x80, 0x00,0x1F,0xE0,0x00,0x0F,0xFC,0x00,0x03,0xCF,0x00,0x00,0xF3,0xC0,0x00,0x78, 0x78,0x00,0x1E,0x1E,0x00,0x0F,0x87,0xC0,0x03,0xC0,0xF0,0x00,0xF0,0x3C,0x00, 0x7C,0x07,0x80,0x1E,0x01,0xE0,0x0F,0x80,0x7C,0x03,0xFF,0xFF,0x00,0xFF,0xFF, 0xC0,0x7F,0xFF,0xF8,0x1E,0x00,0x1E,0x0F,0x80,0x07,0x83,0xC0,0x00,0xF0,0xF0, 0x00,0x3C,0x7C,0x00,0x0F,0x9E,0x00,0x01,0xE7,0x80,0x00,0x7B,0xC0,0x00,0x0F, //'B' size: 6+70 0x42,0x03,0x14,0x1C,0x04,0x1B, 0xFF,0xFC,0x0F,0xFF,0xF0,0xFF,0xFF,0x8F,0x00,0x7C,0xF0,0x03,0xEF,0x00,0x1E,0xF0, 0x01,0xEF,0x00,0x1E,0xF0,0x01,0xEF,0x00,0x3C,0xF0,0x07,0xCF,0xFF,0xF8,0xFF, 0xFE,0x0F,0xFF,0xF8,0xF0,0x07,0xCF,0x00,0x1E,0xF0,0x01,0xEF,0x00,0x0F,0xF0, 0x00,0xFF,0x00,0x0F,0xF0,0x00,0xFF,0x00,0x0F,0xF0,0x01,0xFF,0x00,0x1E,0xF0, 0x07,0xEF,0xFF,0xFC,0xFF,0xFF,0x8F,0xFF,0xC0, //'C' size: 6+84 0x43,0x02,0x17,0x1D,0x02,0x1B, 0x00,0x3F,0xC0,0x03,0xFF,0xF0,0x1F,0xFF,0xF0,0x7F,0x03,0xF1,0xF0,0x00,0xE7,0xC0, 0x00,0xCF,0x00,0x00,0xBE,0x00,0x00,0x78,0x00,0x00,0xF0,0x00,0x03,0xC0,0x00, 0x07,0x80,0x00,0x0F,0x00,0x00,0x1E,0x00,0x00,0x3C,0x00,0x00,0x78,0x00,0x00, 0xF0,0x00,0x01,0xE0,0x00,0x03,0xC0,0x00,0x03,0xC0,0x00,0x07,0x80,0x00,0x0F, 0x80,0x00,0x0F,0x00,0x00,0x9F,0x00,0x03,0x1F,0x00,0x0E,0x1F,0x80,0xFC,0x1F, 0xFF,0xF0,0x0F,0xFF,0xC0,0x03,0xFC,0x00, //'D' size: 6+84 0x44,0x03,0x18,0x1C,0x03,0x1E, 0xFF,0xFC,0x00,0xFF,0xFF,0x80,0xFF,0xFF,0xE0,0xF0,0x07,0xF0,0xF0,0x00,0xF8,0xF0, 0x00,0x7C,0xF0,0x00,0x3C,0xF0,0x00,0x1E,0xF0,0x00,0x1E,0xF0,0x00,0x1F,0xF0, 0x00,0x0F,0xF0,0x00,0x0F,0xF0,0x00,0x0F,0xF0,0x00,0x0F,0xF0,0x00,0x0F,0xF0, 0x00,0x0F,0xF0,0x00,0x0F,0xF0,0x00,0x0F,0xF0,0x00,0x1F,0xF0,0x00,0x1E,0xF0, 0x00,0x1E,0xF0,0x00,0x3E,0xF0,0x00,0x7C,0xF0,0x00,0xF8,0xF0,0x07,0xF0,0xFF, 0xFF,0xE0,0xFF,0xFF,0x80,0xFF,0xFC,0x00, //'E' size: 6+63 0x45,0x03,0x12,0x1C,0x04,0x19, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0xF0,0x00,0x3C,0x00,0x0F,0x00,0x03, 0xC0,0x00,0xF0,0x00,0x3C,0x00,0x0F,0x00,0x03,0xFF,0xFE,0xFF,0xFF,0xBF,0xFF, 0xEF,0x00,0x03,0xC0,0x00,0xF0,0x00,0x3C,0x00,0x0F,0x00,0x03,0xC0,0x00,0xF0, 0x00,0x3C,0x00,0x0F,0x00,0x03,0xC0,0x00,0xF0,0x00,0x3F,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF, //'F' size: 6+56 0x46,0x03,0x10,0x1C,0x03,0x16, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x00,0xF0,0x00,0xF0,0x00,0xF0,0x00,0xF0,0x00, 0xF0,0x00,0xF0,0x00,0xF0,0x00,0xFF,0xFE,0xFF,0xFE,0xFF,0xFE,0xF0,0x00,0xF0, 0x00,0xF0,0x00,0xF0,0x00,0xF0,0x00,0xF0,0x00,0xF0,0x00,0xF0,0x00,0xF0,0x00, 0xF0,0x00,0xF0,0x00,0xF0,0x00,0xF0,0x00,0xF0,0x00, //'G' size: 6+91 0x47,0x02,0x19,0x1D,0x03,0x1E, 0x00,0x3F,0xC0,0x00,0xFF,0xFC,0x01,0xFF,0xFF,0x81,0xFC,0x07,0xE1,0xF0,0x00,0xF1, 0xF0,0x00,0x18,0xF0,0x00,0x04,0xF0,0x00,0x00,0x78,0x00,0x00,0x3C,0x00,0x00, 0x3C,0x00,0x00,0x1E,0x00,0x00,0x0F,0x00,0x00,0x07,0x80,0x00,0x03,0xC0,0x07, 0xFF,0xE0,0x03,0xFF,0xF0,0x01,0xFF,0xF8,0x00,0x03,0xFC,0x00,0x01,0xEF,0x00, 0x00,0xF7,0x80,0x00,0x7B,0xC0,0x00,0x3C,0xF0,0x00,0x1E,0x7C,0x00,0x0F,0x1F, 0x00,0x07,0x87,0xF0,0x0F,0xC1,0xFF,0xFF,0xC0,0x3F,0xFF,0x80,0x03,0xFE,0x00, //'H' size: 6+77 0x48,0x03,0x16,0x1C,0x04,0x1D, 0xF0,0x00,0x3F,0xC0,0x00,0xFF,0x00,0x03,0xFC,0x00,0x0F,0xF0,0x00,0x3F,0xC0,0x00, 0xFF,0x00,0x03,0xFC,0x00,0x0F,0xF0,0x00,0x3F,0xC0,0x00,0xFF,0x00,0x03,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x03,0xFC,0x00,0x0F,0xF0,0x00, 0x3F,0xC0,0x00,0xFF,0x00,0x03,0xFC,0x00,0x0F,0xF0,0x00,0x3F,0xC0,0x00,0xFF, 0x00,0x03,0xFC,0x00,0x0F,0xF0,0x00,0x3F,0xC0,0x00,0xFF,0x00,0x03,0xFC,0x00, 0x0F, //'I' size: 6+14 0x49,0x03,0x04,0x1C,0x04,0x0C, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, //'J' size: 6+45 0x4A,0x03,0x0A,0x24,0x01,0x0C, 0x03,0xC0,0xF0,0x3C,0x0F,0x03,0xC0,0xF0,0x3C,0x0F,0x03,0xC0,0xF0,0x3C,0x0F,0x03, 0xC0,0xF0,0x3C,0x0F,0x03,0xC0,0xF0,0x3C,0x0F,0x03,0xC0,0xF0,0x3C,0x0F,0x03, 0xC0,0xF0,0x3C,0x0F,0x03,0xC0,0xF0,0x7C,0x1E,0x0F,0xBF,0xCF,0xE3,0xE0, //'K' size: 6+77 0x4B,0x03,0x16,0x1C,0x02,0x1A, 0xF0,0x01,0xFB,0xC0,0x0F,0xCF,0x00,0x7E,0x3C,0x03,0xF0,0xF0,0x1F,0x83,0xC0,0xFC, 0x0F,0x07,0xE0,0x3C,0x3F,0x00,0xF1,0xF8,0x03,0xCF,0xC0,0x0F,0x7C,0x00,0x3F, 0xE0,0x00,0xFF,0x00,0x03,0xFC,0x00,0x0F,0xF8,0x00,0x3F,0xF0,0x00,0xF7,0xE0, 0x03,0xCF,0xC0,0x0F,0x0F,0x80,0x3C,0x1F,0x00,0xF0,0x3E,0x03,0xC0,0x7C,0x0F, 0x00,0xF8,0x3C,0x01,0xF0,0xF0,0x03,0xE3,0xC0,0x07,0xCF,0x00,0x0F,0xBC,0x00, 0x1F, //'L' size: 6+63 0x4C,0x03,0x12,0x1C,0x02,0x16, 0xF0,0x00,0x3C,0x00,0x0F,0x00,0x03,0xC0,0x00,0xF0,0x00,0x3C,0x00,0x0F,0x00,0x03, 0xC0,0x00,0xF0,0x00,0x3C,0x00,0x0F,0x00,0x03,0xC0,0x00,0xF0,0x00,0x3C,0x00, 0x0F,0x00,0x03,0xC0,0x00,0xF0,0x00,0x3C,0x00,0x0F,0x00,0x03,0xC0,0x00,0xF0, 0x00,0x3C,0x00,0x0F,0x00,0x03,0xC0,0x00,0xF0,0x00,0x3F,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF, //'M' size: 6+91 0x4D,0x03,0x1A,0x1C,0x04,0x22, 0xFE,0x00,0x1F,0xFF,0xC0,0x0F,0xFF,0xF0,0x03,0xFF,0xFC,0x00,0xFF,0xFF,0x80,0x7F, 0xFD,0xE0,0x1E,0xFF,0x78,0x07,0xBF,0xDF,0x03,0xEF,0xF3,0xC0,0xF3,0xFC,0xF0, 0x3C,0xFF,0x1E,0x1E,0x3F,0xC7,0x87,0x8F,0xF1,0xF3,0xE3,0xFC,0x3C,0xF0,0xFF, 0x0F,0x3C,0x3F,0xC3,0xFF,0x0F,0xF0,0x7F,0x83,0xFC,0x1F,0xE0,0xFF,0x07,0xF8, 0x3F,0xC0,0xFC,0x0F,0xF0,0x3F,0x03,0xFC,0x07,0x80,0xFF,0x01,0xE0,0x3F,0xC0, 0x00,0x0F,0xF0,0x00,0x03,0xFC,0x00,0x00,0xFF,0x00,0x00,0x3F,0xC0,0x00,0x0F, //'N' size: 6+77 0x4E,0x03,0x16,0x1C,0x04,0x1D, 0xFC,0x00,0x3F,0xF0,0x00,0xFF,0xE0,0x03,0xFF,0x80,0x0F,0xFF,0x00,0x3F,0xFE,0x00, 0xFF,0x78,0x03,0xFD,0xF0,0x0F,0xF3,0xC0,0x3F,0xCF,0x80,0xFF,0x1E,0x03,0xFC, 0x7C,0x0F,0xF0,0xF0,0x3F,0xC3,0xE0,0xFF,0x07,0xC3,0xFC,0x0F,0x0F,0xF0,0x3E, 0x3F,0xC0,0x78,0xFF,0x01,0xF3,0xFC,0x03,0xCF,0xF0,0x0F,0xBF,0xC0,0x1F,0xFF, 0x00,0x7F,0xFC,0x00,0xFF,0xF0,0x01,0xFF,0xC0,0x07,0xFF,0x00,0x0F,0xFC,0x00, 0x3F, //'O' size: 6+95 0x4F,0x02,0x1A,0x1D,0x03,0x1F, 0x00,0x7F,0x80,0x00,0x7F,0xF8,0x00,0x7F,0xFF,0x80,0x3F,0x03,0xF0,0x1F,0x00,0x3E, 0x0F,0x80,0x07,0xC3,0xC0,0x00,0xF1,0xF0,0x00,0x3E,0x78,0x00,0x07,0x9E,0x00, 0x01,0xEF,0x00,0x00,0x3F,0xC0,0x00,0x0F,0xF0,0x00,0x03,0xFC,0x00,0x00,0xFF, 0x00,0x00,0x3F,0xC0,0x00,0x0F,0xF0,0x00,0x03,0xFC,0x00,0x00,0xFF,0x00,0x00, 0x3D,0xE0,0x00,0x1E,0x78,0x00,0x07,0x9E,0x00,0x03,0xE3,0xC0,0x00,0xF0,0xF8, 0x00,0x7C,0x1F,0x00,0x3E,0x03,0xF0,0x3F,0x00,0x7F,0xFF,0x80,0x07,0xFF,0x80, 0x00,0x7F,0x80,0x00, //'P' size: 6+63 0x50,0x03,0x12,0x1C,0x03,0x18, 0xFF,0xF0,0x3F,0xFF,0x8F,0xFF,0xF3,0xC0,0x7E,0xF0,0x07,0xBC,0x01,0xFF,0x00,0x3F, 0xC0,0x0F,0xF0,0x03,0xFC,0x00,0xFF,0x00,0x3F,0xC0,0x1F,0xF0,0x07,0xBC,0x07, 0xEF,0xFF,0xF3,0xFF,0xF8,0xFF,0xF8,0x3C,0x00,0x0F,0x00,0x03,0xC0,0x00,0xF0, 0x00,0x3C,0x00,0x0F,0x00,0x03,0xC0,0x00,0xF0,0x00,0x3C,0x00,0x0F,0x00,0x03, 0xC0,0x00, //'Q' size: 6+111 0x51,0x02,0x1A,0x22,0x03,0x1F, 0x00,0x7F,0x80,0x00,0x7F,0xF8,0x00,0x7F,0xFF,0x80,0x3F,0x03,0xF0,0x1F,0x00,0x3E, 0x0F,0x80,0x07,0xC3,0xC0,0x00,0xF1,0xF0,0x00,0x3E,0x78,0x00,0x07,0x9E,0x00, 0x01,0xEF,0x00,0x00,0x3F,0xC0,0x00,0x0F,0xF0,0x00,0x03,0xFC,0x00,0x00,0xFF, 0x00,0x00,0x3F,0xC0,0x00,0x0F,0xF0,0x00,0x03,0xFC,0x00,0x00,0xFF,0x00,0x00, 0x3D,0xE0,0x00,0x1E,0x78,0x00,0x07,0x9E,0x00,0x03,0xE3,0xC0,0x00,0xF0,0xF8, 0x00,0x7C,0x1F,0x00,0x3E,0x03,0xF0,0x3F,0x00,0x7F,0xFF,0x80,0x07,0xFF,0x80, 0x00,0x7F,0xE0,0x00,0x00,0xFC,0x00,0x00,0x1F,0x00,0x00,0x03,0xE0,0x00,0x00, 0x7C,0x00,0x00,0x0F,0x80, //'R' size: 6+77 0x52,0x03,0x16,0x1C,0x03,0x1B, 0xFF,0xF8,0x03,0xFF,0xF8,0x0F,0xFF,0xF0,0x3C,0x07,0xE0,0xF0,0x07,0x83,0xC0,0x0F, 0x0F,0x00,0x3C,0x3C,0x00,0xF0,0xF0,0x03,0xC3,0xC0,0x0F,0x0F,0x00,0x7C,0x3C, 0x01,0xE0,0xF0,0x1F,0x83,0xFF,0xFC,0x0F,0xFF,0xC0,0x3F,0xFF,0x80,0xF0,0x3F, 0x03,0xC0,0x3C,0x0F,0x00,0xF8,0x3C,0x01,0xE0,0xF0,0x07,0xC3,0xC0,0x0F,0x8F, 0x00,0x1E,0x3C,0x00,0x7C,0xF0,0x00,0xF3,0xC0,0x03,0xEF,0x00,0x07,0xBC,0x00, 0x1F, //'S' size: 6+73 0x53,0x02,0x14,0x1D,0x03,0x19, 0x03,0xFC,0x00,0xFF,0xF8,0x3F,0xFF,0xC7,0xE0,0x7C,0x78,0x00,0xCF,0x80,0x04,0xF0, 0x00,0x0F,0x00,0x00,0xF0,0x00,0x0F,0x00,0x00,0xF8,0x00,0x07,0xE0,0x00,0x7F, 0xF0,0x03,0xFF,0xE0,0x0F,0xFF,0x80,0x1F,0xFC,0x00,0x0F,0xE0,0x00,0x3E,0x00, 0x01,0xF0,0x00,0x0F,0x00,0x00,0xF0,0x00,0x0F,0x00,0x00,0xF8,0x00,0x1F,0xE0, 0x03,0xEF,0x80,0x7E,0xFF,0xFF,0xC7,0xFF,0xF0,0x07,0xFC,0x00, //'T' size: 6+84 0x54,0x03,0x18,0x1C,0x00,0x18, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00, 0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00, 0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00, 0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00, 0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00, 0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00, //'U' size: 6+77 0x55,0x03,0x16,0x1C,0x04,0x1D, 0xF0,0x00,0x3F,0xC0,0x00,0xFF,0x00,0x03,0xFC,0x00,0x0F,0xF0,0x00,0x3F,0xC0,0x00, 0xFF,0x00,0x03,0xFC,0x00,0x0F,0xF0,0x00,0x3F,0xC0,0x00,0xFF,0x00,0x03,0xFC, 0x00,0x0F,0xF0,0x00,0x3F,0xC0,0x00,0xFF,0x00,0x03,0xFC,0x00,0x0F,0xF0,0x00, 0x3F,0xC0,0x00,0xFF,0x00,0x03,0xFC,0x00,0x0F,0xF0,0x00,0x3D,0xE0,0x01,0xE7, 0x80,0x07,0x9F,0x00,0x3E,0x3F,0x03,0xF0,0x7F,0xFF,0x80,0xFF,0xFC,0x00,0x7F, 0x80, //'V' size: 6+91 0x56,0x03,0x1A,0x1C,0x01,0x1B, 0xF0,0x00,0x03,0xDE,0x00,0x01,0xE7,0x80,0x00,0x79,0xF0,0x00,0x3E,0x3C,0x00,0x0F, 0x0F,0x00,0x03,0xC1,0xE0,0x01,0xF0,0x78,0x00,0x78,0x1F,0x00,0x3E,0x03,0xC0, 0x0F,0x00,0xF0,0x03,0xC0,0x3E,0x01,0xF0,0x07,0x80,0x78,0x01,0xE0,0x3E,0x00, 0x3C,0x0F,0x00,0x0F,0x03,0xC0,0x03,0xE1,0xF0,0x00,0x78,0x78,0x00,0x1E,0x1E, 0x00,0x03,0xCF,0x00,0x00,0xF3,0xC0,0x00,0x3F,0xF0,0x00,0x07,0xF8,0x00,0x01, 0xFE,0x00,0x00,0x7F,0x80,0x00,0x0F,0xC0,0x00,0x03,0xF0,0x00,0x00,0x78,0x00, //'W' size: 6+126 0x57,0x03,0x24,0x1C,0x02,0x27, 0xF0,0x00,0xF0,0x00,0xFF,0x80,0x1F,0x80,0x1F,0x78,0x01,0xF8,0x01,0xE7,0x80,0x1F, 0x80,0x1E,0x78,0x01,0xF8,0x01,0xE7,0xC0,0x3F,0xC0,0x3E,0x3C,0x03,0x9C,0x03, 0xC3,0xC0,0x39,0xC0,0x3C,0x3C,0x03,0x9C,0x03,0xC3,0xE0,0x79,0xE0,0x7C,0x1E, 0x07,0x0E,0x07,0x81,0xE0,0x70,0xE0,0x78,0x1E,0x07,0x0E,0x07,0x81,0xF0,0xF0, 0xF0,0xF8,0x0F,0x0E,0x07,0x0F,0x00,0xF0,0xE0,0x70,0xF0,0x0F,0x0E,0x07,0x0F, 0x00,0xF9,0xE0,0x79,0xF0,0x07,0x9C,0x03,0x9E,0x00,0x79,0xC0,0x39,0xE0,0x07, 0x9C,0x03,0x9E,0x00,0x7F,0xC0,0x3F,0xE0,0x03,0xF8,0x01,0xFC,0x00,0x3F,0x80, 0x1F,0xC0,0x03,0xF8,0x01,0xFC,0x00,0x3F,0x80,0x1F,0xC0,0x01,0xF0,0x00,0xF8, 0x00,0x1F,0x00,0x0F,0x80, //'X' size: 6+84 0x58,0x03,0x18,0x1C,0x01,0x1A, 0x7C,0x00,0x3E,0x3E,0x00,0x7C,0x1E,0x00,0x78,0x1F,0x00,0xF8,0x0F,0x81,0xF0,0x07, 0x81,0xE0,0x07,0xC3,0xE0,0x03,0xE7,0xC0,0x01,0xE7,0x80,0x01,0xFF,0x80,0x00, 0xFF,0x00,0x00,0xFF,0x00,0x00,0x7E,0x00,0x00,0x7E,0x00,0x00,0x7E,0x00,0x00, 0xFF,0x00,0x01,0xFF,0x80,0x01,0xFF,0x80,0x03,0xE7,0xC0,0x03,0xC3,0xC0,0x07, 0xC3,0xE0,0x0F,0x81,0xF0,0x0F,0x00,0xF0,0x1F,0x00,0xF8,0x3E,0x00,0x7C,0x3C, 0x00,0x3C,0x7C,0x00,0x3E,0xF8,0x00,0x1F, //'Y' size: 6+84 0x59,0x03,0x18,0x1C,0x00,0x18, 0xF8,0x00,0x1F,0x7C,0x00,0x3E,0x3E,0x00,0x7C,0x3E,0x00,0x7C,0x1F,0x00,0xF8,0x0F, 0x81,0xF0,0x0F,0x81,0xF0,0x07,0xC3,0xE0,0x03,0xE7,0xC0,0x03,0xE7,0xC0,0x01, 0xFF,0x80,0x00,0xFF,0x00,0x00,0x7E,0x00,0x00,0x7E,0x00,0x00,0x3C,0x00,0x00, 0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00, 0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00, 0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00, //'Z' size: 6+81 0x5A,0x03,0x17,0x1C,0x02,0x1B, 0xFF,0xFF,0xFD,0xFF,0xFF,0xFB,0xFF,0xFF,0xF0,0x00,0x07,0xE0,0x00,0x0F,0x80,0x00, 0x3E,0x00,0x00,0xF8,0x00,0x03,0xF0,0x00,0x07,0xC0,0x00,0x1F,0x00,0x00,0x7C, 0x00,0x01,0xF0,0x00,0x03,0xE0,0x00,0x0F,0x80,0x00,0x3E,0x00,0x00,0xF8,0x00, 0x01,0xF0,0x00,0x07,0xC0,0x00,0x1F,0x00,0x00,0x7C,0x00,0x01,0xF8,0x00,0x03, 0xE0,0x00,0x0F,0x80,0x00,0x3E,0x00,0x00,0xFC,0x00,0x01,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xF0, //'[' size: 6+40 0x5B,0x01,0x09,0x23,0x03,0x0F, 0xFF,0xFF,0xFF,0xFE,0x0F,0x07,0x83,0xC1,0xE0,0xF0,0x78,0x3C,0x1E,0x0F,0x07,0x83, 0xC1,0xE0,0xF0,0x78,0x3C,0x1E,0x0F,0x07,0x83,0xC1,0xE0,0xF0,0x78,0x3C,0x1E, 0x0F,0x07,0x83,0xC1,0xE0,0xFF,0xFF,0xFF,0xE0, //'\' size: 6+52 0x5C,0x03,0x0D,0x20,0x00,0x0D, 0xE0,0x07,0x80,0x1C,0x00,0xE0,0x07,0x80,0x1C,0x00,0xE0,0x07,0x00,0x1C,0x00,0xE0, 0x07,0x00,0x1C,0x00,0xE0,0x07,0x00,0x3C,0x00,0xE0,0x07,0x00,0x3C,0x00,0xE0, 0x07,0x00,0x38,0x00,0xE0,0x07,0x00,0x38,0x00,0xE0,0x07,0x00,0x38,0x01,0xE0, 0x07,0x00,0x38,0x01,0xE0,0x07, //']' size: 6+40 0x5D,0x01,0x09,0x23,0x03,0x0F, 0xFF,0xFF,0xFF,0xE0,0xF0,0x78,0x3C,0x1E,0x0F,0x07,0x83,0xC1,0xE0,0xF0,0x78,0x3C, 0x1E,0x0F,0x07,0x83,0xC1,0xE0,0xF0,0x78,0x3C,0x1E,0x0F,0x07,0x83,0xC1,0xE0, 0xF0,0x78,0x3C,0x1E,0x0F,0xFF,0xFF,0xFF,0xE0, //'^' size: 6+33 0x5E,0x03,0x18,0x0B,0x05,0x21, 0x00,0x3C,0x00,0x00,0x7E,0x00,0x00,0xFF,0x00,0x01,0xFF,0x80,0x03,0xE7,0xC0,0x07, 0xC3,0xE0,0x0F,0x81,0xF0,0x1E,0x00,0x78,0x3C,0x00,0x3C,0x78,0x00,0x1E,0xF0, 0x00,0x0F, //'_' size: 6+8 0x5F,0x1F,0x14,0x03,0x00,0x14, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0, //'`' size: 6+8 0x60,0x00,0x09,0x07,0x06,0x14, 0xF0,0x3C,0x0F,0x03,0x80,0xE0,0x38,0x0E, //'a' size: 6+50 0x61,0x09,0x12,0x16,0x03,0x18, 0x03,0xF0,0x07,0xFF,0x83,0xFF,0xF0,0xE0,0x7C,0x20,0x07,0x80,0x01,0xE0,0x00,0x3C, 0x00,0x0F,0x00,0x03,0xC1,0xFF,0xF1,0xFF,0xFD,0xFF,0xFF,0x7C,0x03,0xFE,0x00, 0xFF,0x00,0x3F,0xC0,0x1F,0xF0,0x07,0xFE,0x03,0xF7,0xC1,0xFD,0xFF,0xEF,0x3F, 0xF3,0xC3,0xF0,0xF0, //'b' size: 6+72 0x62,0x01,0x13,0x1E,0x03,0x19, 0xF0,0x00,0x1E,0x00,0x03,0xC0,0x00,0x78,0x00,0x0F,0x00,0x01,0xE0,0x00,0x3C,0x00, 0x07,0x80,0x00,0xF0,0xF8,0x1E,0x7F,0xC3,0xDF,0xFC,0x7F,0x07,0xCF,0xC0,0x7D, 0xF0,0x07,0xBE,0x00,0xF7,0x80,0x0F,0xF0,0x01,0xFE,0x00,0x3F,0xC0,0x07,0xF8, 0x00,0xFF,0x00,0x1F,0xE0,0x03,0xFC,0x00,0x7F,0xC0,0x1E,0xF8,0x03,0xDF,0x80, 0xFB,0xF8,0x3E,0x7B,0xFF,0x8F,0x3F,0xE1,0xE1,0xF0,0x00, //'c' size: 6+47 0x63,0x09,0x11,0x16,0x02,0x15, 0x01,0xFC,0x03,0xFF,0x87,0xFF,0xE7,0xE0,0x73,0xE0,0x0B,0xE0,0x01,0xE0,0x01,0xF0, 0x00,0xF0,0x00,0x78,0x00,0x3C,0x00,0x1E,0x00,0x0F,0x00,0x07,0x80,0x03,0xC0, 0x00,0xF0,0x00,0x7C,0x00,0x1E,0x00,0x4F,0xC0,0xE3,0xFF,0xF0,0x7F,0xF0,0x0F, 0xE0, //'d' size: 6+72 0x64,0x01,0x13,0x1E,0x03,0x19, 0x00,0x01,0xE0,0x00,0x3C,0x00,0x07,0x80,0x00,0xF0,0x00,0x1E,0x00,0x03,0xC0,0x00, 0x78,0x00,0x0F,0x03,0xE1,0xE1,0xFF,0x3C,0x7F,0xF7,0x9F,0x07,0xF7,0xC0,0x7E, 0xF0,0x07,0xDE,0x00,0xFF,0x80,0x0F,0xF0,0x01,0xFE,0x00,0x3F,0xC0,0x07,0xF8, 0x00,0xFF,0x00,0x1F,0xE0,0x03,0xFC,0x00,0x7B,0xC0,0x1F,0x78,0x03,0xEF,0x80, 0xFC,0xF8,0x3F,0x8F,0xFE,0xF0,0xFF,0x9E,0x07,0xC3,0xC0, //'e' size: 6+55 0x65,0x09,0x14,0x16,0x02,0x18, 0x01,0xFC,0x00,0x7F,0xF0,0x1F,0xFF,0x83,0xF0,0x7C,0x3C,0x03,0xE7,0x80,0x1E,0x78, 0x00,0xFF,0x00,0x0F,0xF0,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0, 0x00,0x0F,0x00,0x00,0xF0,0x00,0x07,0x80,0x00,0x78,0x00,0x03,0xC0,0x02,0x3F, 0x01,0xE1,0xFF,0xFE,0x07,0xFF,0xC0,0x1F,0xE0, //'f' size: 6+53 0x66,0x01,0x0E,0x1E,0x00,0x0E, 0x01,0xFC,0x1F,0xF0,0xFF,0xC3,0xC0,0x1E,0x00,0x78,0x01,0xE0,0x07,0x80,0x1E,0x03, 0xFF,0xEF,0xFF,0xBF,0xFE,0x1E,0x00,0x78,0x01,0xE0,0x07,0x80,0x1E,0x00,0x78, 0x01,0xE0,0x07,0x80,0x1E,0x00,0x78,0x01,0xE0,0x07,0x80,0x1E,0x00,0x78,0x01, 0xE0,0x07,0x80,0x1E,0x00,0x78,0x00, //'g' size: 6+72 0x67,0x09,0x13,0x1E,0x03,0x19, 0x03,0xE0,0x01,0xFF,0x3C,0x7F,0xF7,0x9F,0x07,0xF7,0xC0,0x7E,0xF0,0x07,0xDE,0x00, 0xFF,0x80,0x0F,0xF0,0x01,0xFE,0x00,0x3F,0xC0,0x07,0xF8,0x00,0xFF,0x00,0x1F, 0xE0,0x03,0xFC,0x00,0x7B,0xC0,0x1F,0x78,0x03,0xEF,0x80,0xFC,0xF8,0x3F,0x8F, 0xFE,0xF0,0xFF,0x9E,0x07,0xC3,0xC0,0x00,0x78,0x00,0x1F,0x00,0x03,0xC2,0x00, 0xF8,0x70,0x3E,0x0F,0xFF,0xC0,0xFF,0xE0,0x07,0xF0,0x00, //'h' size: 6+68 0x68,0x01,0x12,0x1E,0x04,0x19, 0xF0,0x00,0x3C,0x00,0x0F,0x00,0x03,0xC0,0x00,0xF0,0x00,0x3C,0x00,0x0F,0x00,0x03, 0xC0,0x00,0xF0,0xFC,0x3C,0xFF,0x8F,0x7F,0xF3,0xF8,0x3E,0xFC,0x07,0xBE,0x01, 0xFF,0x80,0x3F,0xC0,0x0F,0xF0,0x03,0xFC,0x00,0xFF,0x00,0x3F,0xC0,0x0F,0xF0, 0x03,0xFC,0x00,0xFF,0x00,0x3F,0xC0,0x0F,0xF0,0x03,0xFC,0x00,0xFF,0x00,0x3F, 0xC0,0x0F,0xF0,0x03,0xFC,0x00,0xF0, //'i' size: 6+15 0x69,0x01,0x04,0x1E,0x04,0x0B, 0xFF,0xFF,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, //'j' size: 6+38 0x6A,0x01,0x08,0x26,0x02,0x0B, 0x0F,0x0F,0x0F,0x0F,0x00,0x00,0x00,0x00,0x00,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F, 0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F, 0x0F,0x0F,0x0F,0x1E,0xFE,0xFC,0xF0, //'k' size: 6+72 0x6B,0x01,0x13,0x1E,0x02,0x17, 0xF0,0x00,0x1E,0x00,0x03,0xC0,0x00,0x78,0x00,0x0F,0x00,0x01,0xE0,0x00,0x3C,0x00, 0x07,0x80,0x00,0xF0,0x00,0x1E,0x01,0xFB,0xC0,0x7E,0x78,0x1F,0x8F,0x07,0xE1, 0xE1,0xF8,0x3C,0x7E,0x07,0xBF,0x80,0xFF,0xC0,0x1F,0xF0,0x03,0xFC,0x00,0x7F, 0x80,0x0F,0xF8,0x01,0xEF,0x80,0x3C,0xF8,0x07,0x8F,0x80,0xF0,0xF8,0x1E,0x0F, 0x83,0xC0,0xF8,0x78,0x0F,0x8F,0x00,0xF9,0xE0,0x0F,0xC0, //'l' size: 6+15 0x6C,0x01,0x04,0x1E,0x04,0x0B, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, //'m' size: 6+83 0x6D,0x09,0x1E,0x16,0x04,0x26, 0x00,0xF8,0x07,0xC3,0xCF,0xF0,0x7F,0x8F,0x7F,0xE3,0xFF,0x3F,0x87,0xDC,0x3E,0xFC, 0x0F,0xE0,0x7B,0xE0,0x3F,0x01,0xFF,0x80,0x7C,0x03,0xFC,0x01,0xE0,0x0F,0xF0, 0x07,0x80,0x3F,0xC0,0x1E,0x00,0xFF,0x00,0x78,0x03,0xFC,0x01,0xE0,0x0F,0xF0, 0x07,0x80,0x3F,0xC0,0x1E,0x00,0xFF,0x00,0x78,0x03,0xFC,0x01,0xE0,0x0F,0xF0, 0x07,0x80,0x3F,0xC0,0x1E,0x00,0xFF,0x00,0x78,0x03,0xFC,0x01,0xE0,0x0F,0xF0, 0x07,0x80,0x3F,0xC0,0x1E,0x00,0xF0, //'n' size: 6+50 0x6E,0x09,0x12,0x16,0x04,0x19, 0x00,0xFC,0x3C,0xFF,0x8F,0x7F,0xF3,0xF8,0x3E,0xFC,0x07,0xBE,0x01,0xFF,0x80,0x3F, 0xC0,0x0F,0xF0,0x03,0xFC,0x00,0xFF,0x00,0x3F,0xC0,0x0F,0xF0,0x03,0xFC,0x00, 0xFF,0x00,0x3F,0xC0,0x0F,0xF0,0x03,0xFC,0x00,0xFF,0x00,0x3F,0xC0,0x0F,0xF0, 0x03,0xFC,0x00,0xF0, //'o' size: 6+55 0x6F,0x09,0x14,0x16,0x02,0x18, 0x01,0xF8,0x00,0xFF,0xF0,0x1F,0xFF,0x83,0xF0,0xFC,0x7C,0x03,0xC7,0x80,0x1E,0x78, 0x01,0xEF,0x00,0x0F,0xF0,0x00,0xFF,0x00,0x0F,0xF0,0x00,0xFF,0x00,0x0F,0xF0, 0x00,0xFF,0x00,0x0F,0xF0,0x00,0xF7,0x80,0x1E,0x78,0x01,0xE7,0xC0,0x3C,0x3F, 0x0F,0xC1,0xFF,0xF8,0x0F,0xFF,0x00,0x3F,0x80, //'p' size: 6+72 0x70,0x09,0x13,0x1E,0x03,0x19, 0x00,0xF8,0x1E,0x7F,0xC3,0xDF,0xFC,0x7F,0x07,0xCF,0xC0,0x7D,0xF0,0x07,0xBE,0x00, 0xF7,0x80,0x0F,0xF0,0x01,0xFE,0x00,0x3F,0xC0,0x07,0xF8,0x00,0xFF,0x00,0x1F, 0xE0,0x03,0xFC,0x00,0x7F,0xC0,0x1E,0xF8,0x03,0xDF,0x80,0xFB,0xF8,0x3E,0x7B, 0xFF,0x8F,0x3F,0xE1,0xE1,0xF0,0x3C,0x00,0x07,0x80,0x00,0xF0,0x00,0x1E,0x00, 0x03,0xC0,0x00,0x78,0x00,0x0F,0x00,0x01,0xE0,0x00,0x00, //'q' size: 6+72 0x71,0x09,0x13,0x1E,0x03,0x19, 0x03,0xE0,0x01,0xFF,0x3C,0x7F,0xF7,0x9F,0x07,0xF7,0xC0,0x7E,0xF0,0x07,0xDE,0x00, 0xFF,0x80,0x0F,0xF0,0x01,0xFE,0x00,0x3F,0xC0,0x07,0xF8,0x00,0xFF,0x00,0x1F, 0xE0,0x03,0xFC,0x00,0x7B,0xC0,0x1F,0x78,0x03,0xEF,0x80,0xFC,0xF8,0x3F,0x8F, 0xFE,0xF0,0xFF,0x9E,0x07,0xC3,0xC0,0x00,0x78,0x00,0x0F,0x00,0x01,0xE0,0x00, 0x3C,0x00,0x07,0x80,0x00,0xF0,0x00,0x1E,0x00,0x03,0xC0, //'r' size: 6+36 0x72,0x09,0x0D,0x16,0x02,0x10, 0x00,0xFF,0x9F,0xFD,0xFF,0xFE,0x1F,0xC0,0x7C,0x03,0xE0,0x1E,0x00,0xF0,0x07,0x80, 0x3C,0x01,0xE0,0x0F,0x00,0x78,0x03,0xC0,0x1E,0x00,0xF0,0x07,0x80,0x3C,0x01, 0xE0,0x0F,0x00,0x78,0x00, //'s' size: 6+44 0x73,0x09,0x10,0x16,0x02,0x14, 0x0F,0xF0,0x3F,0xFC,0x7F,0xFE,0x7C,0x0E,0xF8,0x02,0xF0,0x00,0xF0,0x00,0xF0,0x00, 0xF8,0x00,0x7F,0x00,0x3F,0xF0,0x0F,0xFC,0x01,0xFE,0x00,0x3E,0x00,0x0F,0x00, 0x0F,0x00,0x0F,0x80,0x1F,0xF0,0x3E,0xFF,0xFE,0xFF,0xF8,0x3F,0xE0, //'t' size: 6+48 0x74,0x04,0x0E,0x1B,0x01,0x0F, 0x1E,0x00,0x78,0x01,0xE0,0x07,0x80,0x1E,0x00,0x78,0x0F,0xFF,0xFF,0xFF,0xFF,0xFC, 0x78,0x01,0xE0,0x07,0x80,0x1E,0x00,0x78,0x01,0xE0,0x07,0x80,0x1E,0x00,0x78, 0x01,0xE0,0x07,0x80,0x1E,0x00,0x78,0x01,0xE0,0x07,0xC0,0x0F,0xFC,0x1F,0xF0, 0x1F,0xC0, //'u' size: 6+48 0x75,0x0A,0x12,0x15,0x04,0x19, 0xF0,0x03,0xFC,0x00,0xFF,0x00,0x3F,0xC0,0x0F,0xF0,0x03,0xFC,0x00,0xFF,0x00,0x3F, 0xC0,0x0F,0xF0,0x03,0xFC,0x00,0xFF,0x00,0x3F,0xC0,0x0F,0xF0,0x03,0xFC,0x00, 0xFF,0x00,0x7F,0xE0,0x1F,0x78,0x0F,0xDF,0x07,0xF3,0xFF,0xBC,0x7F,0xCF,0x0F, 0xC3,0xC0, //'v' size: 6+56 0x76,0x0A,0x15,0x15,0x01,0x17, 0xF0,0x00,0x7B,0xC0,0x07,0x9E,0x00,0x3C,0xF8,0x03,0xE3,0xC0,0x1E,0x1E,0x00,0xF0, 0x78,0x0F,0x83,0xC0,0x78,0x1F,0x07,0xC0,0x78,0x3C,0x03,0xC1,0xE0,0x1F,0x1F, 0x00,0x78,0xF0,0x03,0xCF,0x80,0x0F,0x78,0x00,0x7B,0xC0,0x03,0xFE,0x00,0x0F, 0xE0,0x00,0x7F,0x00,0x01,0xF8,0x00,0x0F,0x80,0x00, //'w' size: 6+77 0x77,0x0A,0x1D,0x15,0x02,0x20, 0xF0,0x0F,0x80,0x7F,0xC0,0x7C,0x07,0xDE,0x03,0xE0,0x3C,0xF0,0x3F,0x81,0xE7,0x81, 0xDC,0x0F,0x3E,0x0E,0xE0,0xF8,0xF0,0x77,0x07,0x87,0x87,0x9C,0x3C,0x3C,0x38, 0xE1,0xE0,0xF1,0xC7,0x1E,0x07,0x8E,0x38,0xF0,0x3C,0xE0,0xE7,0x81,0xF7,0x07, 0x7C,0x07,0xB8,0x3B,0xC0,0x3F,0xC1,0xFE,0x01,0xFC,0x07,0xF0,0x0F,0xE0,0x3F, 0x80,0x3F,0x01,0xF8,0x01,0xF8,0x0F,0xC0,0x0F,0x80,0x3E,0x00,0x3C,0x01,0xE0, 0x00, //'x' size: 6+56 0x78,0x0A,0x15,0x15,0x01,0x17, 0x7C,0x00,0xF9,0xF0,0x0F,0x87,0xC0,0xF8,0x1F,0x0F,0x80,0xFC,0xFC,0x03,0xE7,0xC0, 0x0F,0xFC,0x00,0x3F,0xC0,0x00,0xFC,0x00,0x07,0xE0,0x00,0x3E,0x00,0x01,0xF8, 0x00,0x1F,0xE0,0x01,0xFF,0x80,0x1F,0x7C,0x01,0xF9,0xF0,0x0F,0x87,0xC0,0xF8, 0x3E,0x0F,0x80,0xF8,0xF8,0x03,0xEF,0xC0,0x0F,0x80, //'y' size: 6+77 0x79,0x0A,0x15,0x1D,0x01,0x17, 0xF8,0x00,0xFB,0xC0,0x07,0x9E,0x00,0x3C,0xF8,0x03,0xE3,0xC0,0x1E,0x1F,0x01,0xF0, 0x78,0x0F,0x03,0xE0,0x78,0x0F,0x07,0xC0,0x78,0x3C,0x03,0xE3,0xE0,0x0F,0x1E, 0x00,0x7D,0xF0,0x01,0xEF,0x00,0x0F,0xF8,0x00,0x3F,0xC0,0x01,0xFC,0x00,0x0F, 0xE0,0x00,0x3E,0x00,0x01,0xF0,0x00,0x0F,0x80,0x00,0x78,0x00,0x07,0xC0,0x00, 0x3C,0x00,0x03,0xE0,0x00,0x3E,0x00,0x0F,0xF0,0x00,0x7F,0x00,0x03,0xE0,0x00, 0x00, //'z' size: 6+45 0x7A,0x0A,0x11,0x15,0x02,0x14, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE0,0x01,0xF0,0x01,0xF0,0x01,0xF0,0x01,0xF0,0x01, 0xF8,0x00,0xF8,0x00,0xF8,0x00,0xF8,0x00,0xF8,0x00,0xFC,0x00,0x7C,0x00,0x7C, 0x00,0x7C,0x00,0x7C,0x00,0x7E,0x00,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xF8, //'{' size: 6+72 0x7B,0x01,0x10,0x24,0x05,0x19, 0x00,0x3F,0x00,0xFF,0x01,0xFF,0x03,0xE0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0, 0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x07,0xC0,0x0F, 0x80,0xFF,0x00,0xFC,0x00,0xFF,0x00,0x0F,0x80,0x07,0xC0,0x03,0xC0,0x03,0xC0, 0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03, 0xC0,0x03,0xC0,0x03,0xE0,0x01,0xFF,0x00,0xFF,0x00,0x3F, //'|' size: 6+15 0x7C,0x01,0x03,0x27,0x05,0x0D, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF8, //'}' size: 6+72 0x7D,0x01,0x10,0x24,0x05,0x19, 0xFC,0x00,0xFF,0x00,0xFF,0x80,0x07,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0, 0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xE0,0x01, 0xF0,0x00,0xFF,0x00,0x3F,0x00,0xFF,0x01,0xF0,0x03,0xE0,0x03,0xC0,0x03,0xC0, 0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03, 0xC0,0x03,0xC0,0x07,0xC0,0xFF,0x80,0xFF,0x00,0xFC,0x00, //'~' size: 6+18 0x7E,0x10,0x18,0x06,0x05,0x21, 0x0F,0xC0,0x01,0x3F,0xF0,0x03,0x7F,0xFE,0x0F,0xF0,0x7F,0xFE,0xC0,0x0F,0xFC,0x80, 0x03,0xF0, //'' size: 6+85 0x7F,0x03,0x14,0x22,0x02,0x17, 0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0x3C,0x00,0x03,0xC0,0x00,0x3C,0x00,0x03,0xC0, 0x00,0x3C,0x00,0x03,0xC0,0x00,0x3C,0x00,0x03,0xC0,0x00,0x3C,0x00,0x03,0xC0, 0x00,0x3C,0x00,0x03,0xC0,0x00,0x3C,0x00,0x03,0xC0,0x00,0x3C,0x00,0x03,0xC0, 0x00,0x3C,0x00,0x03,0xC0,0x00,0x3C,0x00,0x03,0xC0,0x00,0x3C,0x00,0x03,0xC0, 0x00,0x3C,0x00,0x03,0xC0,0x00,0x3C,0x00,0x03,0xC0,0x00,0x3C,0x00,0x03,0xC0, 0x00,0x3C,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xFF, // Terminator 0xFF };
YifuLiu/AliOS-Things
components/py_engine/modules/display/esp32/tft/font/DejaVuSans40.c
C
apache-2.0
35,537
#ifndef __FONT__H__ #define __FONT__H__ // To incloud uint*_t head file #include "esp_system.h" typedef struct { // Data stored PER GLYPH uint32_t bitmapOffset; // Pointer into GFXfont->bitmap uint8_t width, height; // Bitmap dimensions in pixels uint8_t xAdvance; // Distance to advance cursor (x axis) int8_t xOffset, yOffset; // Dist from cursor pos to UL corner } GFXglyph; // 0x7F, 0xB6, 0xD2, 0x49, 0x20, 0x1B, /* 0x0021 */ typedef struct { uint16_t start; uint16_t end; uint16_t base; } EncodeRange; typedef struct { // Data stored for FONT AS A WHOLE: uint8_t *bitmap; // Glyph bitmaps, concatenated GFXglyph *glyph; // Glyph array uint16_t first, last; // ASCII extents uint8_t yAdvance; // Newline distance (y axis) uint16_t range_num; EncodeRange *range; } GFXfont; #endif
YifuLiu/AliOS-Things
components/py_engine/modules/display/esp32/tft/font/font.h
C
apache-2.0
839
#ifndef _GFX_H__ #define _GFX_H__ #include "string.h" #include "py/obj.h" #include "py/mperrno.h" #include "py/runtime.h" #include "../tft/tftspi.h" #include "font/font.h" extern int unicode_printProportionalChar(uint32_t code, int x, int y); extern const GFXfont *gfx_font; extern int16_t GetUnicodeWidth(uint32_t code); extern int unicode_rotateProChar(uint32_t code, int x, int y, uint16_t offset); #endif
YifuLiu/AliOS-Things
components/py_engine/modules/display/esp32/tft/gfx.h
C
apache-2.0
411
/* * This file is part of the MicroPython ESP32 project, https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo * * The MIT License (MIT) * * Copyright (c) 2018 LoBo (https://github.com/loboris) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ /* STMPE610 Touch controller constants */ #ifndef _STMPE610_H #define _STMPE610_H #include "sdkconfig.h" #include <stdint.h> #define STMPE610_SPI_MODE 0 // Identification registers #define STMPE610_REG_CHP_ID 0x00 // 16-bit #define STMPE610_REG_ID_VER 0x02 // System registers #define STMPE610_REG_SYS_CTRL1 0x03 #define STMPE610_REG_SYS_CTRL2 0x04 #define STMPE610_REG_SPI_CFG 0x08 // Interrupt control registers #define STMPE610_REG_INT_CTRL 0x09 #define STMPE610_REG_INT_EN 0x0A #define STMPE610_REG_INT_STA 0x0B #define STMPE610_REG_GPIO_INT_EN 0x0C #define STMPE610_REG_GPIO_INT_STA 0x0D #define STMPE610_REG_ADC_INT_EN 0x0E #define STMPE610_REG_ADC_INT_STA 0x0F // GPIO registers #define STMPE610_REG_GPIO_SET_PIN 0x10 #define STMPE610_REG_GPIO_CLR_PIN 0x11 #define STMPE610_REG_GPIO_MP_STA 0x12 #define STMPE610_REG_GPIO_DIR 0x13 #define STMPE610_REG_GPIO_ED 0x14 #define STMPE610_REG_GPIO_RE 0x15 #define STMPE610_REG_GPIO_FE 0x16 #define STMPE610_REG_GPIO_AF 0x17 // ADC registers #define STMPE610_REG_ADC_CTRL1 0x20 #define STMPE610_REG_ADC_CTRL2 0x21 #define STMPE610_REG_ADC_CAPT 0x22 #define STMPE610_REG_ADC_DATA_CH0 0x30 // 16-bit #define STMPE610_REG_ADC_DATA_CH1 0x32 // 16-bit #define STMPE610_REG_ADC_DATA_CH4 0x38 // 16-bit #define STMPE610_REG_ADC_DATA_CH5 0x3A // 16-bit #define STMPE610_REG_ADC_DATA_CH6 0x3C // 16-bit #define STMPE610_REG_ADC_DATA_CH7 0x3E // 16-bit // Touchscreen registers #define STMPE610_REG_TSC_CTRL 0x40 #define STMPE610_REG_TSC_CFG 0x41 #define STMPE610_REG_WDW_TR_X 0x42 // 16-bit #define STMPE610_REG_WDW_TR_Y 0x44 // 16-bit #define STMPE610_REG_WDW_BL_X 0x46 // 16-bit #define STMPE610_REG_WDW_BL_Y 0x48 // 16-bit #define STMPE610_REG_FIFO_TH 0x4A #define STMPE610_REG_FIFO_STA 0x4B #define STMPE610_REG_FIFO_SIZE 0x4C #define STMPE610_REG_TSC_DATA_X 0x4D // 16-bit #define STMPE610_REG_TSC_DATA_Y 0x4F // 16-bit #define STMPE610_REG_TSC_DATA_Z 0x51 #define STMPE610_REG_TSC_DATA_XYZ 0x52 // 32-bit #define STMPE610_REG_TSC_FRACT_XYZ 0x56 #define STMPE610_REG_TSC_DATA 0x57 #define STMPE610_REG_TSC_I_DRIVE 0x58 #define STMPE610_REG_TSC_SHIELD 0x59 #define STMPE610_REG_TSC_CTRL_EN 0x01 #define STMPE610_REG_TSC_CTRL_XYZ 0x00 #define STMPE610_REG_TSC_CTRL_XY 0x02 #define STMPE610_REG_INT_EN 0x0A #define STMPE610_REG_INT_EN_TOUCHDET 0x01 #define STMPE610_REG_INT_EN_FIFOTH 0x02 #define STMPE610_REG_INT_EN_FIFOOF 0x04 #define STMPE610_REG_INT_EN_FIFOFULL 0x08 #define STMPE610_REG_INT_EN_FIFOEMPTY 0x10 #define STMPE610_REG_INT_EN_ADC 0x40 #define STMPE610_REG_INT_EN_GPIO 0x80 #define STMPE610_REG_ADC_CTRL1_12BIT 0x08 #define STMPE610_REG_ADC_CTRL1_10BIT 0x00 #define STMPE610_REG_ADC_CTRL2_1_625MHZ 0x00 #define STMPE610_REG_ADC_CTRL2_3_25MHZ 0x01 #define STMPE610_REG_ADC_CTRL2_6_5MHZ 0x02 #define STMPE610_REG_ADC_CTRL2_1_625MHZ 0x00 #define STMPE610_REG_ADC_CTRL2_3_25MHZ 0x01 #define STMPE610_REG_ADC_CTRL2_6_5MHZ 0x02 #define STMPE610_REG_TSC_CFG_1SAMPLE 0x00 #define STMPE610_REG_TSC_CFG_2SAMPLE 0x40 #define STMPE610_REG_TSC_CFG_4SAMPLE 0x80 #define STMPE610_REG_TSC_CFG_8SAMPLE 0xC0 #define STMPE610_REG_TSC_CFG_DELAY_10US 0x00 #define STMPE610_REG_TSC_CFG_DELAY_50US 0x08 #define STMPE610_REG_TSC_CFG_DELAY_100US 0x10 #define STMPE610_REG_TSC_CFG_DELAY_500US 0x18 #define STMPE610_REG_TSC_CFG_DELAY_1MS 0x20 #define STMPE610_REG_TSC_CFG_DELAY_5MS 0x28 #define STMPE610_REG_TSC_CFG_DELAY_10MS 0x30 #define STMPE610_REG_TSC_CFG_DELAY_50MS 0x38 #define STMPE610_REG_TSC_CFG_SETTLE_10US 0x00 #define STMPE610_REG_TSC_CFG_SETTLE_100US 0x01 #define STMPE610_REG_TSC_CFG_SETTLE_500US 0x02 #define STMPE610_REG_TSC_CFG_SETTLE_1MS 0x03 #define STMPE610_REG_TSC_CFG_SETTLE_5MS 0x04 #define STMPE610_REG_TSC_CFG_SETTLE_10MS 0x05 #define STMPE610_REG_TSC_CFG_SETTLE_50MS 0x06 #define STMPE610_REG_TSC_CFG_SETTLE_100MS 0x07 #define STMPE610_REG_FIFO_STA_RESET 0x01 #define STMPE610_REG_FIFO_STA_OFLOW 0x80 #define STMPE610_REG_FIFO_STA_FULL 0x40 #define STMPE610_REG_FIFO_STA_EMPTY 0x20 #define STMPE610_REG_FIFO_STA_THTRIG 0x10 #define STMPE610_REG_TSC_I_DRIVE_20MA 0x00 #define STMPE610_REG_TSC_I_DRIVE_50MA 0x01 #define STMPE610_REG_INT_CTRL_POL_HIGH 0x04 #define STMPE610_REG_INT_CTRL_POL_LOW 0x00 #define STMPE610_REG_INT_CTRL_EDGE 0x02 #define STMPE610_REG_INT_CTRL_LEVEL 0x00 #define STMPE610_REG_INT_CTRL_ENABLE 0x01 #define STMPE610_REG_INT_CTRL_DISABLE 0x00 #endif // CONFIG_MICROPY_USE_TFT
YifuLiu/AliOS-Things
components/py_engine/modules/display/esp32/tft/stmpe610.h
C
apache-2.0
5,897
/* * This file is part of the MicroPython ESP32 project, https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo * * The MIT License (MIT) * * Copyright (c) 2018 LoBo (https://github.com/loboris) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ /* * TFT library * * Author: LoBo, 01/2018 * * Library supporting SPI TFT displays based on ILI9341, ILI9488 & ST7789V controllers */ #include "sdkconfig.h" #include <errno.h> #include <string.h> #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "esp_system.h" #include "tft.h" #include "time.h" #include <math.h> #include "esp_heap_caps.h" #include "tftspi.h" #include "py/mpprint.h" #include "gfx.h" #include "extmod/vfs_lfs.h" #include "lib/littlefs/lfs2.h" #include "extmod/vfs.h" #define DWORD _DWORD #include "tjpgd.h" #undef DWORD #define DEG_TO_RAD 0.01745329252 #define RAD_TO_DEG 57.295779513 #define deg_to_rad 0.01745329252 + 3.14159265359 #define swap(a, b) \ { \ int16_t t = a; \ a = b; \ b = t; \ } #define constrain(amt, low, high) ((amt) < (low) ? (low) : ((amt) > (high) ? (high) : (amt))) #if !defined(max) #define max(A, B) ((A) > (B) ? (A) : (B)) #endif #if !defined(min) #define min(A, B) ((A) < (B) ? (A) : (B)) #endif /* These types must be 16-bit, 32-bit or larger integer */ typedef int INT; typedef unsigned int UINT; /* These types must be 8-bit integer */ typedef char CHAR; typedef unsigned char UCHAR; typedef unsigned char BYTE; /* These types must be 16-bit integer */ typedef short SHORT; typedef unsigned short USHORT; typedef unsigned short WORD; typedef unsigned short WCHAR; // Embedded fonts // extern uint8_t tft_SmallFont[]; extern uint8_t tft_DefaultFont[]; extern uint8_t tft_Dejavu18[]; extern uint8_t tft_Dejavu24[]; extern uint8_t tft_Dejavu40[]; #if 0 extern uint8_t tft_Dejavu56[]; extern uint8_t tft_Dejavu72[]; extern uint8_t tft_Ubuntu16[]; extern uint8_t tft_Comic24[]; extern uint8_t tft_minya24[]; extern uint8_t tft_tooney32[]; extern uint8_t tft_def_small[]; extern uint8_t tft_Arial12[]; extern uint8_t tft_Arial16[]; #endif // ==== Color definitions constants ============== const color_t TFT_BLACK = {0, 0, 0}; const color_t TFT_NAVY = {0, 0, 128}; const color_t TFT_DARKGREEN = {0, 128, 0}; const color_t TFT_DARKCYAN = {0, 128, 128}; const color_t TFT_MAROON = {128, 0, 0}; const color_t TFT_PURPLE = {128, 0, 128}; const color_t TFT_OLIVE = {128, 128, 0}; const color_t TFT_LIGHTGREY = {192, 192, 192}; const color_t TFT_DARKGREY = {128, 128, 128}; const color_t TFT_BLUE = {0, 0, 255}; const color_t TFT_GREEN = {0, 255, 0}; const color_t TFT_CYAN = {0, 255, 255}; const color_t TFT_RED = {252, 0, 0}; const color_t TFT_MAGENTA = {252, 0, 255}; const color_t TFT_YELLOW = {252, 252, 0}; const color_t TFT_WHITE = {252, 252, 252}; const color_t TFT_ORANGE = {252, 164, 0}; const color_t TFT_GREENYELLOW = {172, 252, 44}; const color_t TFT_PINK = {252, 192, 202}; // =============================================== // ============================================================== // ==== Set default values of global variables ================== uint8_t tft_active_mode = TFT_MODE_TFT; uint8_t orientation = LANDSCAPE; // screen orientation uint16_t font_rotate = 0; // font rotation uint8_t font_transparent = 0; uint8_t font_forceFixed = 0; uint8_t text_wrap = 0; // character wrapping to new line color_t _fg = {0, 255, 0}; color_t _bg = {0, 0, 0}; uint8_t image_debug = 0; uint8_t font_now = 0; uint16_t image_width = 0; uint16_t image_hight = 0; float _angleOffset = DEFAULT_ANGLE_OFFSET; int TFT_X = 0; int TFT_Y = 0; uint32_t tp_calx = 0; uint32_t tp_caly = 0; dispWin_t dispWin = { .x1 = 0, .y1 = 0, .x2 = DEFAULT_TFT_DISPLAY_WIDTH, .y2 = DEFAULT_TFT_DISPLAY_HEIGHT, }; Font cfont = { .font = tft_DefaultFont, .x_size = 0, .y_size = 0x0B, .offset = 0, .numchars = 95, .bitmap = 1, }; uint8_t font_buffered_char = 1; uint8_t font_line_space = 0; // ------------------------ // ePaper display variables // ------------------------ uint8_t *drawBuff = NULL; uint8_t *gs_drawBuff = NULL; uint8_t _gs = 0; uint16_t gs_used_shades = 0; // unicode #define NOTFOUNDINDEX 10 // extern const GFXfont unicode_24px; // const GFXfont *gfx_font = &unicode_24px; #if 0 // ============================================================== STATIC lfs2_t *lookup_path(const char *path, const char **path_out) { mp_vfs_mount_t *fs = mp_vfs_lookup_path(path, path_out); if (fs == MP_VFS_NONE || fs == MP_VFS_ROOT) { return NULL; } // here we assume that the mounted device is FATFS return &((mp_obj_vfs_lfs2_t*)MP_OBJ_TO_PTR(fs->obj))->lfs; } #endif typedef struct { uint8_t charCode; int adjYOffset; int width; int height; int xOffset; int xDelta; uint16_t dataPtr; } propFont; static dispWin_t dispWinTemp; static uint8_t *userfont = NULL; static int TFT_OFFSET = 0; static propFont fontChar; static float _arcAngleMax = DEFAULT_ARC_ANGLE_MAX; static bool image_trans = false; // ========================================================================= // ** All drawings are clipped to 'dispWin' ** // ** All x,y coordinates in public functions are relative to clip window ** // =========== : Public functions // ----------- : Local functions // ========================================================================= // Compare two colors; return 0 if equal // ============================================ int TFT_compare_colors(color_t c1, color_t c2) { if ((c1.r & 0xFC) != (c2.r & 0xFC)) return 1; if ((c1.g & 0xFC) != (c2.g & 0xFC)) return 1; if ((c1.b & 0xFC) != (c2.b & 0xFC)) return 1; return 0; } // ==== EPD low level functions ==================================================== // -------------------------------------------------- // static void EPD_drawPixel(int x, int y, uint8_t val) // { // if (orientation == LANDSCAPE_FLIP) { // x = _width - x - 1; // y = _height - y - 1; // } // if (_gs) { // val &= 0x0F; // //if (gs_drawBuff[(y * _width) + x] != val) { // gs_drawBuff[(y * _width) + x] = val; // gs_used_shades |= (1<<val); // //} // } // else { // val &= 0x01; // uint8_t buf_val = drawBuff[(x * (_height >> 3)) + (y>>3)]; // uint8_t new_val = buf_val; // if (val) new_val &= (0x80 >> (y % 8)) ^ 0xFF; // else new_val |= (0x80 >> (y % 8)); // //if (new_val != buf_val) drawBuff[(x * (_height>>3)) + (y>>3)] = new_val; // drawBuff[(x * (_height>>3)) + (y>>3)] = new_val; // } // } // ------------------------------------------------------------------------- // static void EPD_pushColorRep(int x1, int y1, int x2, int y2, uint8_t color) // { // if (_gs == 0) color &= 0x01; // else color &= 0x0F; // for (int y=y1; y<=y2; y++) { // for (int x = x1; x<=x2; x++){ // EPD_drawPixel(x, y, color); // } // } // } // =========================================================================================== // ------------------------------------ dispWin_t dispWin_save; static esp_err_t TFT_EPD_disp_select() { return disp_select(); } // -------------------------------------- static esp_err_t TFT_EPD_disp_deselect() { return disp_deselect(); } // ----------------------------------------------------------------------------------------------------- static void TFT_EPD_send_data(int x1, int y1, int x2, int y2, uint32_t len, color_t *buf, uint8_t wait) { send_data(x1, y1, x2, y2, len, buf, wait); } // draw color pixel on screen // ---------------------------------------------------------------------- static void TFT_EPD_drawPixe(int16_t x, int16_t y, color_t color, uint8_t sel) { if ((x < dispWin.x1) || (y < dispWin.y1) || (x > dispWin.x2) || (y > dispWin.y2)) return; if (tft_active_mode == TFT_MODE_TFT) drawPixel(x, y, color, sel); } // ------------------------------------------------------------------------------------------- static void TFT_EPD_pushColorRep(int x1, int y1, int x2, int y2, color_t color, uint32_t len) { if (len == 0) return; if (tft_active_mode == TFT_MODE_TFT) TFT_pushColorRep(x1, y1, x2, y2, color, len); } // =========================================================================================== // ==================================================================== void TFT_drawPixel(int16_t x, int16_t y, color_t color, uint8_t sel) { TFT_EPD_drawPixe(x + dispWin.x1, y + dispWin.y1, color, sel); } // =========================================== color_t TFT_readPixel(int16_t x, int16_t y) { if ((x < dispWin.x1) || (y < dispWin.y1) || (x > dispWin.x2) || (y > dispWin.y2)) return TFT_BLACK; return readPixel(x, y); } // -------------------------------------------------------------------------- static void _drawFastVLine(int16_t x, int16_t y, int16_t h, color_t color) { // clipping if ((x < dispWin.x1) || (x > dispWin.x2) || (y > dispWin.y2)) return; if (y < dispWin.y1) { h -= (dispWin.y1 - y); y = dispWin.y1; } if (h < 0) h = 0; if ((y + h) > (dispWin.y2 + 1)) h = dispWin.y2 - y + 1; if (h == 0) h = 1; TFT_EPD_pushColorRep(x, y, x, y + h - 1, color, (uint32_t)h); } // -------------------------------------------------------------------------- static void _drawFastHLine(int16_t x, int16_t y, int16_t w, color_t color) { // clipping if ((y < dispWin.y1) || (x > dispWin.x2) || (y > dispWin.y2)) return; if (x < dispWin.x1) { w -= (dispWin.x1 - x); x = dispWin.x1; } if (w < 0) w = 0; if ((x + w) > (dispWin.x2 + 1)) w = dispWin.x2 - x + 1; if (w == 0) w = 1; TFT_EPD_pushColorRep(x, y, x + w - 1, y, color, (uint32_t)w); } // ====================================================================== void TFT_drawFastVLine(int16_t x, int16_t y, int16_t h, color_t color) { _drawFastVLine(x + dispWin.x1, y + dispWin.y1, h, color); } // ====================================================================== void TFT_drawFastHLine(int16_t x, int16_t y, int16_t w, color_t color) { _drawFastHLine(x + dispWin.x1, y + dispWin.y1, w, color); } // Bresenham's algorithm, speed enhanced by Bodmer this uses // the efficient FastH/V Line draw routine for segments of 2 pixels or more // ---------------------------------------------------------------------------------- static void _drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, color_t color) { if (x0 == x1) { if (y0 <= y1) _drawFastVLine(x0, y0, y1 - y0 + 1, color); else _drawFastVLine(x0, y1, y0 - y1 + 1, color); return; } if (y0 == y1) { if (x0 <= x1) _drawFastHLine(x0, y0, x1 - x0 + 1, color); else _drawFastHLine(x1, y0, x0 - x1 + 1, color); return; } int steep = 0; if (abs(y1 - y0) > abs(x1 - x0)) steep = 1; if (steep) { swap(x0, y0); swap(x1, y1); } if (x0 > x1) { swap(x0, x1); swap(y0, y1); } int16_t dx = x1 - x0, dy = abs(y1 - y0); int16_t err = dx >> 1, ystep = -1, xs = x0, dlen = 0; if (y0 < y1) ystep = 1; // Split into steep and not steep for FastH/V separation if (steep) { for (; x0 <= x1; x0++) { dlen++; err -= dy; if (err < 0) { err += dx; if (dlen == 1) TFT_EPD_drawPixe(y0, xs, color, 1); else _drawFastVLine(y0, xs, dlen, color); dlen = 0; y0 += ystep; xs = x0 + 1; } } if (dlen) _drawFastVLine(y0, xs, dlen, color); } else { for (; x0 <= x1; x0++) { dlen++; err -= dy; if (err < 0) { err += dx; if (dlen == 1) TFT_EPD_drawPixe(xs, y0, color, 1); else _drawFastHLine(xs, y0, dlen, color); dlen = 0; y0 += ystep; xs = x0 + 1; } } if (dlen) _drawFastHLine(xs, y0, dlen, color); } } // ============================================================================== void TFT_drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, color_t color) { _drawLine(x0 + dispWin.x1, y0 + dispWin.y1, x1 + dispWin.x1, y1 + dispWin.y1, color); } // fill a rectangle // -------------------------------------------------------------------------------- static void _fillRect(int16_t x, int16_t y, int16_t w, int16_t h, color_t color) { // clipping if ((x >= dispWin.x2) || (y > dispWin.y2)) return; if (x < dispWin.x1) { w -= (dispWin.x1 - x); x = dispWin.x1; } if (y < dispWin.y1) { h -= (dispWin.y1 - y); y = dispWin.y1; } if (w < 0) w = 0; if (h < 0) h = 0; if ((x + w) > (dispWin.x2 + 1)) w = dispWin.x2 - x + 1; if ((y + h) > (dispWin.y2 + 1)) h = dispWin.y2 - y + 1; if (w == 0) w = 1; if (h == 0) h = 1; TFT_EPD_pushColorRep(x, y, x + w - 1, y + h - 1, color, (uint32_t)(h * w)); } // ============================================================================ void TFT_fillRect(int16_t x, int16_t y, int16_t w, int16_t h, color_t color) { _fillRect(x + dispWin.x1, y + dispWin.y1, w, h, color); } // ================================== void TFT_fillScreen(color_t color) { TFT_EPD_pushColorRep(0, 0, _width - 1, _height - 1, color, (uint32_t)(_height * _width)); } // ================================== void TFT_fillWindow(color_t color) { TFT_EPD_pushColorRep(dispWin.x1, dispWin.y1, dispWin.x2, dispWin.y2, color, (uint32_t)((dispWin.x2 - dispWin.x1 + 1) * (dispWin.y2 - dispWin.y1 + 1))); } // ^^^============= Basics drawing functions ================================^^^ // ================ Graphics drawing functions ================================== // ----------------------------------------------------------------------------------- static void _drawRect(uint16_t x1, uint16_t y1, uint16_t w, uint16_t h, color_t color) { _drawFastHLine(x1, y1, w, color); _drawFastVLine(x1 + w - 1, y1, h, color); _drawFastHLine(x1, y1 + h - 1, w, color); _drawFastVLine(x1, y1, h, color); } // =============================================================================== void TFT_drawRect(uint16_t x1, uint16_t y1, uint16_t w, uint16_t h, color_t color) { _drawRect(x1 + dispWin.x1, y1 + dispWin.y1, w, h, color); } // ------------------------------------------------------------------------------------------------- static void drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, color_t color) { int16_t f = 1 - r; int16_t ddF_x = 1; int16_t ddF_y = -2 * r; int16_t x = 0; int16_t y = r; TFT_EPD_disp_select(); while (x < y) { if (f >= 0) { y--; ddF_y += 2; f += ddF_y; } x++; ddF_x += 2; f += ddF_x; if (cornername & 0x4) { TFT_EPD_drawPixe(x0 + x, y0 + y, color, 0); TFT_EPD_drawPixe(x0 + y, y0 + x, color, 0); } if (cornername & 0x2) { TFT_EPD_drawPixe(x0 + x, y0 - y, color, 0); TFT_EPD_drawPixe(x0 + y, y0 - x, color, 0); } if (cornername & 0x8) { TFT_EPD_drawPixe(x0 - y, y0 + x, color, 0); TFT_EPD_drawPixe(x0 - x, y0 + y, color, 0); } if (cornername & 0x1) { TFT_EPD_drawPixe(x0 - y, y0 - x, color, 0); TFT_EPD_drawPixe(x0 - x, y0 - y, color, 0); } } TFT_EPD_disp_deselect(); } // Used to do circles and roundrects // ---------------------------------------------------------------------------------------------------------------- static void fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, color_t color) { int16_t f = 1 - r; int16_t ddF_x = 1; int16_t ddF_y = -2 * r; int16_t x = 0; int16_t y = r; int16_t ylm = x0 - r; while (x < y) { if (f >= 0) { if (cornername & 0x1) _drawFastVLine(x0 + y, y0 - x, 2 * x + 1 + delta, color); if (cornername & 0x2) _drawFastVLine(x0 - y, y0 - x, 2 * x + 1 + delta, color); ylm = x0 - y; y--; ddF_y += 2; f += ddF_y; } x++; ddF_x += 2; f += ddF_x; if ((x0 - x) > ylm) { if (cornername & 0x1) _drawFastVLine(x0 + x, y0 - y, 2 * y + 1 + delta, color); if (cornername & 0x2) _drawFastVLine(x0 - x, y0 - y, 2 * y + 1 + delta, color); } } } // Draw a rounded rectangle // ============================================================================================= void TFT_drawRoundRect(int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t r, color_t color) { x += dispWin.x1; y += dispWin.y1; // smarter version _drawFastHLine(x + r, y, w - 2 * r, color); // Top _drawFastHLine(x + r, y + h - 1, w - 2 * r, color); // Bottom _drawFastVLine(x, y + r, h - 2 * r, color); // Left _drawFastVLine(x + w - 1, y + r, h - 2 * r, color); // Right // draw four corners drawCircleHelper(x + r, y + r, r, 1, color); drawCircleHelper(x + w - r - 1, y + r, r, 2, color); drawCircleHelper(x + w - r - 1, y + h - r - 1, r, 4, color); drawCircleHelper(x + r, y + h - r - 1, r, 8, color); } // Fill a rounded rectangle // ============================================================================================= void TFT_fillRoundRect(int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t r, color_t color) { x += dispWin.x1; y += dispWin.y1; // smarter version _fillRect(x + r, y, w - 2 * r, h, color); // draw four corners fillCircleHelper(x + w - r - 1, y + r, r, 1, h - 2 * r - 1, color); fillCircleHelper(x + r, y + r, r, 2, h - 2 * r - 1, color); } // ----------------------------------------------------------------------------------------------- static void _drawLineByAngle(int16_t x, int16_t y, int16_t angle, uint16_t length, color_t color) { _drawLine( x, y, x + length * cos((angle + _angleOffset) * DEG_TO_RAD), y + length * sin((angle + _angleOffset) * DEG_TO_RAD), color); } // --------------------------------------------------------------------------------------------------------------- static void _DrawLineByAngle(int16_t x, int16_t y, int16_t angle, uint16_t start, uint16_t length, color_t color) { _drawLine( x + start * cos((angle + _angleOffset) * DEG_TO_RAD), y + start * sin((angle + _angleOffset) * DEG_TO_RAD), x + (start + length) * cos((angle + _angleOffset) * DEG_TO_RAD), y + (start + length) * sin((angle + _angleOffset) * DEG_TO_RAD), color); } // =========================================================================================================== void TFT_drawLineByAngle(uint16_t x, uint16_t y, uint16_t start, uint16_t len, uint16_t angle, color_t color) { x += dispWin.x1; y += dispWin.y1; if (start == 0) _drawLineByAngle(x, y, angle, len, color); else _DrawLineByAngle(x, y, angle, start, len, color); } // Draw a triangle // -------------------------------------------------------------------------------------------------------------------- static void _drawTriangle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, color_t color) { _drawLine(x0, y0, x1, y1, color); _drawLine(x1, y1, x2, y2, color); _drawLine(x2, y2, x0, y0, color); } // ================================================================================================================ void TFT_drawTriangle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, color_t color) { x0 += dispWin.x1; y0 += dispWin.y1; x1 += dispWin.x1; y1 += dispWin.y1; x2 += dispWin.x1; y2 += dispWin.y1; _drawLine(x0, y0, x1, y1, color); _drawLine(x1, y1, x2, y2, color); _drawLine(x2, y2, x0, y0, color); } // Fill a triangle // -------------------------------------------------------------------------------------------------------------------- static void _fillTriangle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, color_t color) { int16_t a, b, y, last; // Sort coordinates by Y order (y2 >= y1 >= y0) if (y0 > y1) { swap(y0, y1); swap(x0, x1); } if (y1 > y2) { swap(y2, y1); swap(x2, x1); } if (y0 > y1) { swap(y0, y1); swap(x0, x1); } if (y0 == y2) { // Handle awkward all-on-same-line case as its own thing a = b = x0; if (x1 < a) a = x1; else if (x1 > b) b = x1; if (x2 < a) a = x2; else if (x2 > b) b = x2; _drawFastHLine(a, y0, b - a + 1, color); return; } int16_t dx01 = x1 - x0, dy01 = y1 - y0, dx02 = x2 - x0, dy02 = y2 - y0, dx12 = x2 - x1, dy12 = y2 - y1; int32_t sa = 0, sb = 0; // For upper part of triangle, find scanline crossings for segments // 0-1 and 0-2. If y1=y2 (flat-bottomed triangle), the scanline y1 // is included here (and second loop will be skipped, avoiding a /0 // error there), otherwise scanline y1 is skipped here and handled // in the second loop...which also avoids a /0 error here if y0=y1 // (flat-topped triangle). if (y1 == y2) last = y1; // Include y1 scanline else last = y1 - 1; // Skip it for (y = y0; y <= last; y++) { a = x0 + sa / dy01; b = x0 + sb / dy02; sa += dx01; sb += dx02; /* longhand: a = x0 + (x1 - x0) * (y - y0) / (y1 - y0); b = x0 + (x2 - x0) * (y - y0) / (y2 - y0); */ if (a > b) swap(a, b); _drawFastHLine(a, y, b - a + 1, color); } // For lower part of triangle, find scanline crossings for segments // 0-2 and 1-2. This loop is skipped if y1=y2. sa = dx12 * (y - y1); sb = dx02 * (y - y0); for (; y <= y2; y++) { a = x1 + sa / dy12; b = x0 + sb / dy02; sa += dx12; sb += dx02; /* longhand: a = x1 + (x2 - x1) * (y - y1) / (y2 - y1); b = x0 + (x2 - x0) * (y - y0) / (y2 - y0); */ if (a > b) swap(a, b); _drawFastHLine(a, y, b - a + 1, color); } } // ================================================================================================================ void TFT_fillTriangle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, color_t color) { _fillTriangle( x0 + dispWin.x1, y0 + dispWin.y1, x1 + dispWin.x1, y1 + dispWin.y1, x2 + dispWin.x1, y2 + dispWin.y1, color); } // ==================================================================== void TFT_drawCircle(int16_t x, int16_t y, int radius, color_t color) { x += dispWin.x1; y += dispWin.y1; int f = 1 - radius; int ddF_x = 1; int ddF_y = -2 * radius; int x1 = 0; int y1 = radius; TFT_EPD_disp_select(); TFT_EPD_drawPixe(x, y + radius, color, 0); TFT_EPD_drawPixe(x, y - radius, color, 0); TFT_EPD_drawPixe(x + radius, y, color, 0); TFT_EPD_drawPixe(x - radius, y, color, 0); while (x1 < y1) { if (f >= 0) { y1--; ddF_y += 2; f += ddF_y; } x1++; ddF_x += 2; f += ddF_x; TFT_EPD_drawPixe(x + x1, y + y1, color, 0); TFT_EPD_drawPixe(x - x1, y + y1, color, 0); TFT_EPD_drawPixe(x + x1, y - y1, color, 0); TFT_EPD_drawPixe(x - x1, y - y1, color, 0); TFT_EPD_drawPixe(x + y1, y + x1, color, 0); TFT_EPD_drawPixe(x - y1, y + x1, color, 0); TFT_EPD_drawPixe(x + y1, y - x1, color, 0); TFT_EPD_drawPixe(x - y1, y - x1, color, 0); } TFT_EPD_disp_deselect(); } // ==================================================================== void TFT_fillCircle(int16_t x, int16_t y, int radius, color_t color) { x += dispWin.x1; y += dispWin.y1; _drawFastVLine(x, y - radius, 2 * radius + 1, color); fillCircleHelper(x, y, radius, 3, 0, color); } // ==================================================================== void TFT_drawSwitchBtn(int16_t x, int16_t y, int width, int hight, color_t color, color_t switch_color, uint8_t state) { if (hight >= width + 2) return; if (hight % 2) hight += 1; int16_t radius = hight / 2; if (radius < 5) return; TFT_drawRoundRect(x, y, width, hight, radius, color); if (state) { TFT_fillCircle(x + width - radius - 1, y + radius, radius - 3, switch_color); } else { TFT_fillCircle(x + radius, y + radius, radius - 3, switch_color); } } // ---------------------------------------------------------------------------------------------------------------- static void _draw_ellipse_section(uint16_t x, uint16_t y, uint16_t x0, uint16_t y0, color_t color, uint8_t option) { TFT_EPD_disp_select(); // upper right if (option & TFT_ELLIPSE_UPPER_RIGHT) TFT_EPD_drawPixe(x0 + x, y0 - y, color, 0); // upper left if (option & TFT_ELLIPSE_UPPER_LEFT) TFT_EPD_drawPixe(x0 - x, y0 - y, color, 0); // lower right if (option & TFT_ELLIPSE_LOWER_RIGHT) TFT_EPD_drawPixe(x0 + x, y0 + y, color, 0); // lower left if (option & TFT_ELLIPSE_LOWER_LEFT) TFT_EPD_drawPixe(x0 - x, y0 + y, color, 0); TFT_EPD_disp_deselect(); } // ===================================================================================================== void TFT_drawEllipse(uint16_t x0, uint16_t y0, uint16_t rx, uint16_t ry, color_t color, uint8_t option) { x0 += dispWin.x1; y0 += dispWin.y1; uint16_t x, y; int32_t xchg, ychg; int32_t err; int32_t rxrx2; int32_t ryry2; int32_t stopx, stopy; rxrx2 = rx; rxrx2 *= rx; rxrx2 *= 2; ryry2 = ry; ryry2 *= ry; ryry2 *= 2; x = rx; y = 0; xchg = 1; xchg -= rx; xchg -= rx; xchg *= ry; xchg *= ry; ychg = rx; ychg *= rx; err = 0; stopx = ryry2; stopx *= rx; stopy = 0; while (stopx >= stopy) { _draw_ellipse_section(x, y, x0, y0, color, option); y++; stopy += rxrx2; err += ychg; ychg += rxrx2; if (2 * err + xchg > 0) { x--; stopx -= ryry2; err += xchg; xchg += ryry2; } } x = 0; y = ry; xchg = ry; xchg *= ry; ychg = 1; ychg -= ry; ychg -= ry; ychg *= rx; ychg *= rx; err = 0; stopx = 0; stopy = rxrx2; stopy *= ry; while (stopx <= stopy) { _draw_ellipse_section(x, y, x0, y0, color, option); x++; stopx += ryry2; err += xchg; xchg += ryry2; if (2 * err + ychg > 0) { y--; stopy -= rxrx2; err += ychg; ychg += rxrx2; } } } // ----------------------------------------------------------------------------------------------------------------------- static void _draw_filled_ellipse_section(uint16_t x, uint16_t y, uint16_t x0, uint16_t y0, color_t color, uint8_t option) { // upper right if (option & TFT_ELLIPSE_UPPER_RIGHT) _drawFastVLine(x0 + x, y0 - y, y + 1, color); // upper left if (option & TFT_ELLIPSE_UPPER_LEFT) _drawFastVLine(x0 - x, y0 - y, y + 1, color); // lower right if (option & TFT_ELLIPSE_LOWER_RIGHT) _drawFastVLine(x0 + x, y0, y + 1, color); // lower left if (option & TFT_ELLIPSE_LOWER_LEFT) _drawFastVLine(x0 - x, y0, y + 1, color); } // ===================================================================================================== void TFT_fillEllipse(uint16_t x0, uint16_t y0, uint16_t rx, uint16_t ry, color_t color, uint8_t option) { x0 += dispWin.x1; y0 += dispWin.y1; uint16_t x, y; int32_t xchg, ychg; int32_t err; int32_t rxrx2; int32_t ryry2; int32_t stopx, stopy; rxrx2 = rx; rxrx2 *= rx; rxrx2 *= 2; ryry2 = ry; ryry2 *= ry; ryry2 *= 2; x = rx; y = 0; xchg = 1; xchg -= rx; xchg -= rx; xchg *= ry; xchg *= ry; ychg = rx; ychg *= rx; err = 0; stopx = ryry2; stopx *= rx; stopy = 0; while (stopx >= stopy) { _draw_filled_ellipse_section(x, y, x0, y0, color, option); y++; stopy += rxrx2; err += ychg; ychg += rxrx2; if (2 * err + xchg > 0) { x--; stopx -= ryry2; err += xchg; xchg += ryry2; } } x = 0; y = ry; xchg = ry; xchg *= ry; ychg = 1; ychg -= ry; ychg -= ry; ychg *= rx; ychg *= rx; err = 0; stopx = 0; stopy = rxrx2; stopy *= ry; while (stopx <= stopy) { _draw_filled_ellipse_section(x, y, x0, y0, color, option); x++; stopx += ryry2; err += xchg; xchg += ryry2; if (2 * err + ychg > 0) { y--; stopy -= rxrx2; err += ychg; ychg += rxrx2; } } } // ==== ARC DRAWING =================================================================== // --------------------------------------------------------------------------------------------------------------------------------- static void _fillArcOffsetted(uint16_t cx, uint16_t cy, uint16_t radius, uint16_t thickness, float start, float end, color_t color) { // float sslope = (float)cos_lookup(start) / (float)sin_lookup(start); // float eslope = (float)cos_lookup(end) / (float)sin_lookup(end); float sslope = (cos(start / _arcAngleMax * 2 * PI) * _arcAngleMax) / (sin(start / _arcAngleMax * 2 * PI) * _arcAngleMax); float eslope = (cos(end / _arcAngleMax * 2 * PI) * _arcAngleMax) / (sin(end / _arcAngleMax * 2 * PI) * _arcAngleMax); if (end == 360) eslope = -1000000; int ir2 = (radius - thickness) * (radius - thickness); int or2 = radius * radius; TFT_EPD_disp_select(); for (int x = -radius; x <= radius; x++) { for (int y = -radius; y <= radius; y++) { int x2 = x * x; int y2 = y * y; if ( (x2 + y2 < or2 && x2 + y2 >= ir2) && ((y > 0 && start < 180 && x <= y * sslope) || (y < 0 && start > 180 && x >= y * sslope) || (y < 0 && start <= 180) || (y == 0 && start <= 180 && x < 0) || (y == 0 && start == 0 && x > 0)) && ((y > 0 && end < 180 && x >= y * eslope) || (y < 0 && end > 180 && x <= y * eslope) || (y > 0 && end >= 180) || (y == 0 && end >= 180 && x < 0) || (y == 0 && start == 0 && x > 0))) TFT_EPD_drawPixe(cx + x, cy + y, color, 0); } } TFT_EPD_disp_deselect(); } // =========================================================================================================================== void TFT_drawArc(uint16_t cx, uint16_t cy, uint16_t r, uint16_t th, float start, float end, color_t color, color_t fillcolor) { cx += dispWin.x1; cy += dispWin.y1; if (th < 1) th = 1; if (th > r) th = r; int f = TFT_compare_colors(fillcolor, color); float astart = fmodf(start, _arcAngleMax); float aend = fmodf(end, _arcAngleMax); astart += _angleOffset; aend += _angleOffset; if (astart < 0) astart += (float)360; if (aend < 0) aend += (float)360; if (aend == 0) aend = (float)360; if (astart > aend) { _fillArcOffsetted(cx, cy, r, th, astart, _arcAngleMax, fillcolor); _fillArcOffsetted(cx, cy, r, th, 0, aend, fillcolor); if (f) { _fillArcOffsetted(cx, cy, r, 1, astart, _arcAngleMax, color); _fillArcOffsetted(cx, cy, r, 1, 0, aend, color); _fillArcOffsetted(cx, cy, r - th, 1, astart, _arcAngleMax, color); _fillArcOffsetted(cx, cy, r - th, 1, 0, aend, color); } } else { _fillArcOffsetted(cx, cy, r, th, astart, aend, fillcolor); if (f) { _fillArcOffsetted(cx, cy, r, 1, astart, aend, color); _fillArcOffsetted(cx, cy, r - th, 1, astart, aend, color); } } if (f) { _drawLine(cx + (r - th) * cos(astart * DEG_TO_RAD), cy + (r - th) * sin(astart * DEG_TO_RAD), cx + (r - 1) * cos(astart * DEG_TO_RAD), cy + (r - 1) * sin(astart * DEG_TO_RAD), color); _drawLine(cx + (r - th) * cos(aend * DEG_TO_RAD), cy + (r - th) * sin(aend * DEG_TO_RAD), cx + (r - 1) * cos(aend * DEG_TO_RAD), cy + (r - 1) * sin(aend * DEG_TO_RAD), color); } } // ============================================================================================================= void TFT_drawPolygon(int cx, int cy, int sides, int diameter, color_t color, color_t fill, int rot, uint8_t th) { cx += dispWin.x1; cy += dispWin.y1; int deg = rot - _angleOffset; int f = TFT_compare_colors(fill, color); if (sides < MIN_POLIGON_SIDES) sides = MIN_POLIGON_SIDES; // This ensures the minimum side number if (sides > MAX_POLIGON_SIDES) sides = MAX_POLIGON_SIDES; // This ensures the maximum side number int Xpoints[sides], Ypoints[sides]; // Set the arrays based on the number of sides entered int rads = 360 / sides; // This equally spaces the points. for (int idx = 0; idx < sides; idx++) { Xpoints[idx] = cx + sin((float)(idx * rads + deg) * deg_to_rad) * diameter; Ypoints[idx] = cy + cos((float)(idx * rads + deg) * deg_to_rad) * diameter; } // Draw the polygon on the screen. if (f) { for (int idx = 0; idx < sides; idx++) { if ((idx + 1) < sides) _fillTriangle(cx, cy, Xpoints[idx], Ypoints[idx], Xpoints[idx + 1], Ypoints[idx + 1], fill); else _fillTriangle(cx, cy, Xpoints[idx], Ypoints[idx], Xpoints[0], Ypoints[0], fill); } } if (th) { for (int n = 0; n < th; n++) { if (n > 0) { for (int idx = 0; idx < sides; idx++) { Xpoints[idx] = cx + sin((float)(idx * rads + deg) * deg_to_rad) * (diameter - n); Ypoints[idx] = cy + cos((float)(idx * rads + deg) * deg_to_rad) * (diameter - n); } } for (int idx = 0; idx < sides; idx++) { if ((idx + 1) < sides) _drawLine(Xpoints[idx], Ypoints[idx], Xpoints[idx + 1], Ypoints[idx + 1], color); // draw the lines else _drawLine(Xpoints[idx], Ypoints[idx], Xpoints[0], Ypoints[0], color); // finishes the last line to close up the polygon. } } } } /* // Similar to the Polygon function. // ===================================================================================== void TFT_drawStar(int cx, int cy, int diameter, color_t color, bool fill, float factor) { cx += dispWin.x1; cy += dispWin.y1; factor = constrain(factor, 1.0, 4.0); uint8_t sides = 5; uint8_t rads = 360 / sides; int Xpoints_O[sides], Ypoints_O[sides], Xpoints_I[sides], Ypoints_I[sides];//Xpoints_T[5], Ypoints_T[5]; for(int idx = 0; idx < sides; idx++) { // makes the outer points Xpoints_O[idx] = cx + sin((float)(idx*rads + 72) * deg_to_rad) * diameter; Ypoints_O[idx] = cy + cos((float)(idx*rads + 72) * deg_to_rad) * diameter; // makes the inner points Xpoints_I[idx] = cx + sin((float)(idx*rads + 36) * deg_to_rad) * ((float)(diameter)/factor); // 36 is half of 72, and this will allow the inner and outer points to line up like a triangle. Ypoints_I[idx] = cy + cos((float)(idx*rads + 36) * deg_to_rad) * ((float)(diameter)/factor); } for(int idx = 0; idx < sides; idx++) { if((idx+1) < sides) { if(fill) {// this part below should be self explanatory. It fills in the star. _fillTriangle(cx,cy,Xpoints_I[idx],Ypoints_I[idx],Xpoints_O[idx],Ypoints_O[idx], color); _fillTriangle(cx,cy,Xpoints_O[idx],Ypoints_O[idx],Xpoints_I[idx+1],Ypoints_I[idx+1], color); } else { _drawLine(Xpoints_O[idx],Ypoints_O[idx],Xpoints_I[idx+1],Ypoints_I[idx+1], color); _drawLine(Xpoints_I[idx],Ypoints_I[idx],Xpoints_O[idx],Ypoints_O[idx], color); } } else { if(fill) { _fillTriangle(cx,cy,Xpoints_I[0],Ypoints_I[0],Xpoints_O[idx],Ypoints_O[idx], color); _fillTriangle(cx,cy,Xpoints_O[idx],Ypoints_O[idx],Xpoints_I[idx],Ypoints_I[idx], color); } else { _drawLine(Xpoints_O[idx],Ypoints_O[idx],Xpoints_I[idx],Ypoints_I[idx], color); _drawLine(Xpoints_I[0],Ypoints_I[0],Xpoints_O[idx],Ypoints_O[idx], color); } } } } */ // ================ Font and string functions ================================== // -------------------------------------------------------- static int load_file_font(const char *fontfile, int info) { int err = 0; // char err_msg[256] = {'\0'}; // if (userfont != NULL) { // free(userfont); // userfont = NULL; // } // struct stat sb; // spi_device_deselect(disp_spi); // spi_device_deselect(ts_spi); // // Open the file // FILE *fhndl = fopen(fontfile, "rb"); // if (fhndl == NULL) { // sprintf(err_msg, "Error opening font file '%s'", fontfile); // err = 1; // goto exit; // } // // Get file size // if (stat(fontfile, &sb) != 0) { // sprintf(err_msg, "Error getting font file size"); // err = 2; // goto exit; // } // int fsize = sb.st_size; // if (fsize < 30) { // sprintf(err_msg, "Error getting font file size"); // err = 3; // goto exit; // } // userfont = malloc(fsize+4); // if (userfont == NULL) { // sprintf(err_msg, "Font memory allocation error"); // fclose(fhndl); // err = 4; // goto exit; // } // int read = fread(userfont, 1, fsize, fhndl); // fclose(fhndl); // if (read != fsize) { // sprintf(err_msg, "Font read error"); // err = 5; // goto exit; // } // userfont[read] = 0; // if (strstr((char *)(userfont+read-8), "RPH_font") == NULL) { // sprintf(err_msg, "Font ID not found"); // err = 6; // goto exit; // } // // Check size // int size = 0; // int numchar = 0; // int width = userfont[0]; // int height = userfont[1]; // uint8_t first = 255; // uint8_t last = 0; // //int offst = 0; // int pminwidth = 255; // int pmaxwidth = 0; // if (width != 0) { // // Fixed font // numchar = userfont[3]; // first = userfont[2]; // last = first + numchar - 1; // size = ((width * height * numchar) / 8) + 4; // } // else { // // Proportional font // size = 4; // point at first char data // uint8_t charCode; // int charwidth; // do { // charCode = userfont[size]; // charwidth = userfont[size+2]; // if (charCode != 0xFF) { // numchar++; // if (charwidth != 0) size += ((((charwidth * userfont[size+3])-1) / 8) + 7); // else size += 6; // if (info) { // if (charwidth > pmaxwidth) pmaxwidth = charwidth; // if (charwidth < pminwidth) pminwidth = charwidth; // if (charCode < first) first = charCode; // if (charCode > last) last = charCode; // } // } // else size++; // } while ((size < (read-8)) && (charCode != 0xFF)); // } // if (size != (read-8)) { // sprintf(err_msg, "Font size error: found %d expected %d)", size, (read-8)); // err = 7; // goto exit; // } // if (info) { // if (width != 0) { // mp_printf(&mp_plat_print, "Fixed width font:\r\n size: %d width: %d height: %d characters: %d (%d~%d)\n", // size, width, height, numchar, first, last); // } // else { // mp_printf(&mp_plat_print, "Proportional font:\r\n size: %d width: %d~%d height: %d characters: %d (%d~%d)\n", // size, pminwidth, pmaxwidth, height, numchar, first, last); // } // } // exit: // if (err) { // if (userfont) { // free(userfont); // userfont = NULL; // } // if (info) mp_printf(&mp_plat_print, "Error: %d [%s]\r\n", err, err_msg); // } return err; } // ------------------------------------------------ int compile_font_file(char *fontfile, uint8_t dbg) { int err = 0; // char err_msg[128] = {'\0'}; // char outfile[128] = {'\0'}; // size_t len; // struct stat sb; // FILE *ffd = NULL; // FILE *ffd_out = NULL; // char *sourcebuf = NULL; // len = strlen(fontfile); // // check here that filename end with ".c". // if ((len < 3) || (len > 125) || (strcmp(fontfile + len - 2, ".c") != 0)) { // sprintf(err_msg, "not a .c file"); // err = 1; // goto exit; // } // sprintf(outfile, "%s", fontfile); // sprintf(outfile+strlen(outfile)-1, "fon"); // // Open the source file // if (stat(fontfile, &sb) != 0) { // sprintf(err_msg, "Error opening source file '%s'", fontfile); // err = 2; // goto exit; // } // // Open the file // ffd = fopen(fontfile, "rb"); // if (!ffd) { // sprintf(err_msg, "Error opening source file '%s'", fontfile); // err = 3; // goto exit; // } // // Open the font file // ffd_out= fopen(outfile, "wb"); // if (!ffd_out) { // sprintf(err_msg, "error opening destination file"); // err = 4; // goto exit; // } // // Get file size // int fsize = sb.st_size; // if (fsize <= 0) { // sprintf(err_msg, "source file size error"); // err = 5; // goto exit; // } // sourcebuf = malloc(fsize+4); // if (sourcebuf == NULL) { // sprintf(err_msg, "memory allocation error"); // err = 6; // goto exit; // } // char *fbuf = sourcebuf; // int rdsize = fread(fbuf, 1, fsize, ffd); // fclose(ffd); // ffd = NULL; // if (rdsize != fsize) { // sprintf(err_msg, "error reading from source file"); // err = 7; // goto exit; // } // *(fbuf+rdsize) = '\0'; // fbuf = strchr(fbuf, '{'); // beginning of font data // char *fend = strstr(fbuf, "};"); // end of font data // if ((fbuf == NULL) || (fend == NULL) || ((fend-fbuf) < 22)) { // sprintf(err_msg, "wrong source file format"); // err = 8; // goto exit; // } // fbuf++; // *fend = '\0'; // char hexstr[5] = {'\0'}; // int lastline = 0; // fbuf = strstr(fbuf, "0x"); // int size = 0; // char *nextline; // char *numptr; // int bptr = 0; // while ((fbuf != NULL) && (fbuf < fend) && (lastline == 0)) { // nextline = strchr(fbuf, '\n'); // beginning of the next line // if (nextline == NULL) { // nextline = fend-1; // lastline++; // } // else nextline++; // while (fbuf < nextline) { // numptr = strstr(fbuf, "0x"); // if ((numptr == NULL) || ((fbuf+4) > nextline)) numptr = strstr(fbuf, "0X"); // if ((numptr != NULL) && ((numptr+4) <= nextline)) { // fbuf = numptr; // if (bptr >= 128) { // // buffer full, write to file // if (fwrite(outfile, 1, 128, ffd_out) != 128) goto error; // bptr = 0; // size += 128; // } // memcpy(hexstr, fbuf, 4); // hexstr[4] = 0; // outfile[bptr++] = (uint8_t)strtol(hexstr, NULL, 0); // fbuf += 4; // } // else fbuf = nextline; // } // fbuf = nextline; // } // if (bptr > 0) { // size += bptr; // if (fwrite(outfile, 1, bptr, ffd_out) != bptr) goto error; // } // // write font ID // sprintf(outfile, "RPH_font"); // if (fwrite(outfile, 1, 8, ffd_out) != 8) goto error; // fclose(ffd_out); // ffd_out = NULL; // // === Test compiled font === // sprintf(outfile, "%s", fontfile); // sprintf(outfile+strlen(outfile)-1, "fon"); // uint8_t *uf = userfont; // save userfont pointer // userfont = NULL; // if (load_file_font(outfile, 1) != 0) { // sprintf(err_msg, "Error compiling file!"); // err = 10; // } // else { // free(userfont); // sprintf(err_msg, "File compiled successfully."); // } // userfont = uf; // restore userfont // goto exit; // error: // sprintf(err_msg, "error writing to destination file"); // err = 9; // exit: // if (sourcebuf) free(sourcebuf); // if (ffd) fclose(ffd); // if (ffd_out) fclose(ffd_out); // if (dbg) mp_printf(&mp_plat_print, "%s\r\n", err_msg); return err; } // ----------------------------------------------------------------------------------------- // Individual Proportional Font Character Format: // ----------------------------------------------------------------------------------------- // Character Code // yOffset (start Y of visible pixels) // Width (width of the visible pixels) // Height (height of the visible pixels) // xOffset (start X of visible pixels) // xDelta (the distance to move the cursor. Effective width of the character.) // Data[n] // ----------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------- // Character drawing rectangle is (0, 0) (xDelta-1, cfont.y_size-1) // Character visible pixels rectangle is (xOffset, yOffset) (xOffset+Width-1, yOffset+Height-1) // --------------------------------------------------------------------------------------------- // ---------------------------------- void getFontCharacters(uint8_t *buf) { if (cfont.bitmap == 2) { // For 7 segment font only characters 0,1,2,3,4,5,6,7,8,9, . , - , : , / are available. for (uint8_t n = 0; n < 11; n++) { buf[n] = n + 0x30; } buf[11] = '.'; buf[12] = '-'; buf[13] = '/'; buf[14] = '\0'; return; } if (cfont.x_size > 0) { for (uint8_t n = 0; n < cfont.numchars; n++) { buf[n] = cfont.offset + n; } buf[cfont.numchars] = '\0'; return; } uint16_t tempPtr = 4; // point at first char data uint8_t cc, cw, ch, n; n = 0; cc = cfont.font[tempPtr++]; while (cc != 0xFF) { cfont.numchars++; tempPtr++; cw = cfont.font[tempPtr++]; ch = cfont.font[tempPtr++]; tempPtr++; tempPtr++; if (cw != 0) { // packed bits tempPtr += (((cw * ch) - 1) / 8) + 1; } buf[n++] = cc; cc = cfont.font[tempPtr++]; } buf[n] = '\0'; } // Set max width & height of the proportional font // ----------------------------- static void getMaxWidthHeight() { uint16_t tempPtr = 4; // point at first char data uint8_t cc, cw, ch, cd, cy; cfont.numchars = 0; cfont.max_x_size = 0; cc = cfont.font[tempPtr++]; while (cc != 0xFF) { cfont.numchars++; cy = cfont.font[tempPtr++]; cw = cfont.font[tempPtr++]; ch = cfont.font[tempPtr++]; tempPtr++; cd = cfont.font[tempPtr++]; cy += ch; if (cw > cfont.max_x_size) cfont.max_x_size = cw; if (cd > cfont.max_x_size) cfont.max_x_size = cd; if (ch > cfont.y_size) cfont.y_size = ch; if (cy > cfont.y_size) cfont.y_size = cy; if (cw != 0) { // packed bits tempPtr += (((cw * ch) - 1) / 8) + 1; } cc = cfont.font[tempPtr++]; } cfont.size = tempPtr; } // Return the Glyph data for an individual character in the proportional font // ------------------------------------ static uint8_t getCharPtr(uint8_t c) { uint16_t tempPtr = 4; // point at first char data do { fontChar.charCode = cfont.font[tempPtr++]; if (fontChar.charCode == 0xFF) return 0; fontChar.adjYOffset = cfont.font[tempPtr++]; fontChar.width = cfont.font[tempPtr++]; fontChar.height = cfont.font[tempPtr++]; fontChar.xOffset = cfont.font[tempPtr++]; fontChar.xOffset = fontChar.xOffset < 0x80 ? fontChar.xOffset : -(0xFF - fontChar.xOffset); fontChar.xDelta = cfont.font[tempPtr++]; if (c != fontChar.charCode && fontChar.charCode != 0xFF) { if (fontChar.width != 0) { // packed bits tempPtr += (((fontChar.width * fontChar.height) - 1) / 8) + 1; } } } while ((c != fontChar.charCode) && (fontChar.charCode != 0xFF)); fontChar.dataPtr = tempPtr; if (c == fontChar.charCode) { if (font_forceFixed > 0) { // fix width & offset for forced fixed width fontChar.xDelta = cfont.max_x_size; fontChar.xOffset = (fontChar.xDelta - fontChar.width) / 2; } } else { return 0; } return 1; } /* const char fontnames[] = { "FONT_Default", "FONT_DejaVu18", "FONT_DejaVu24", "FONT_Ubuntu", "FONT_Comic", "FONT_Minya", "FONT_Tooney", "FONT_Small", "FONT_DefaultSmall", "FONT_7seg", "External font" }; // --------------------- void fontProperties() { if (cfont.x_size) { mp_printf(&mp_plat_print, "FONT TEST: fixed font\r\n"); return; } uint16_t tempPtr = 4; // point at first char data uint8_t c = 0x20; for (c=0x20; c <0xFF; c++) { fontChar.charCode = cfont.font[tempPtr++]; if (fontChar.charCode == 0xFF) break; if (fontChar.charCode != c) { mp_printf(&mp_plat_print, "FONT TEST: last sequential char: %d, expected %d\r\n", fontChar.charCode, c); break; } c = fontChar.charCode; fontChar.adjYOffset = cfont.font[tempPtr++]; fontChar.width = cfont.font[tempPtr++]; fontChar.height = cfont.font[tempPtr++]; fontChar.xOffset = cfont.font[tempPtr++]; fontChar.xOffset = fontChar.xOffset < 0x80 ? fontChar.xOffset : -(0xFF - fontChar.xOffset); fontChar.xDelta = cfont.font[tempPtr++]; if (fontChar.charCode != 0xFF) { if (fontChar.width != 0) { // packed bits tempPtr += (((fontChar.width * fontChar.height)-1) / 8) + 1; } } } mp_printf(&mp_plat_print, "FONT TEST: W=%d H=%d last char: %d [%c]; length: %d\r\n", cfont.max_x_size, cfont.y_size, c, c, tempPtr); } */ // =================================================== void TFT_setFont(uint8_t font, const char *font_file) { cfont.font = NULL; font_now = font; // if (font == UNICODE_FONT) { // font = DEJAVU24_FONT; // font_transparent = false; // } if (font == FONT_7SEG) { cfont.bitmap = 2; cfont.x_size = 24; cfont.y_size = 6; cfont.offset = 0; cfont.color = _fg; } else { if (font == USER_FONT) { if (load_file_font(font_file, 0) != 0) cfont.font = tft_DefaultFont; else cfont.font = userfont; } else if (font == DEJAVU18_FONT) cfont.font = tft_Dejavu18; else if (font == DEJAVU24_FONT) cfont.font = tft_Dejavu24; else if (font == DEJAVU40_FONT) cfont.font = tft_Dejavu40; #if 0 else if (font == DEJAVU56_FONT) cfont.font = tft_Dejavu56; else if (font == DEJAVU72_FONT) cfont.font = tft_Dejavu72; // else if (font == UBUNTU16_FONT) cfont.font = tft_Ubuntu16; else if (font == COMIC24_FONT) cfont.font = tft_Comic24; else if (font == ARIAL12_FONT) cfont.font = tft_Arial12; else if (font == ARIAL16_FONT) cfont.font = tft_Arial16; else if (font == MINYA24_FONT) cfont.font = tft_minya24; else if (font == TOONEY32_FONT) cfont.font = tft_tooney32; else if (font == SMALL_FONT) cfont.font = tft_SmallFont; else if (font == DEF_SMALL_FONT) cfont.font = tft_def_small; #endif else cfont.font = tft_DefaultFont; cfont.bitmap = 1; cfont.x_size = cfont.font[0]; cfont.y_size = cfont.font[1]; if (cfont.x_size > 0) { cfont.offset = cfont.font[2]; cfont.numchars = cfont.font[3]; cfont.size = cfont.x_size * cfont.y_size * cfont.numchars; } else { cfont.offset = 4; getMaxWidthHeight(); } //_testFont(); } } // ----------------------------------------------------------------------------------------- // Individual Proportional Font Character Format: // ----------------------------------------------------------------------------------------- // Character Code // yOffset (start Y of visible pixels) // Width (width of the visible pixels) // Height (height of the visible pixels) // xOffset (start X of visible pixels) // xDelta (the distance to move the cursor. Effective width of the character.) // Data[n] // ----------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------- // Character drawing rectangle is (0, 0) (xDelta-1, cfont.y_size-1) // Character visible pixels rectangle is (xOffset, yOffset) (xOffset+Width-1, yOffset+Height-1) // --------------------------------------------------------------------------------------------- // print non-rotated proportional character // character is already in fontChar // ---------------------------------------------- static int printProportionalChar(int x, int y) { uint8_t ch = 0; int i, j, char_width; char_width = ((fontChar.width > fontChar.xDelta) ? fontChar.width : fontChar.xDelta); if ((font_buffered_char) && (!font_transparent)) { int len, bufPos; // === buffer Glyph data for faster sending === len = (char_width + 1) * cfont.y_size; color_t *color_line = malloc(len * 3); if (color_line) { // fill with background color for (int n = 0; n < len; n++) { color_line[n] = _bg; } // set character pixels to foreground color uint8_t mask = 0x80; for (j = 0; j < fontChar.height; j++) { for (i = 0; i < fontChar.width; i++) { if (((i + (j * fontChar.width)) % 8) == 0) { mask = 0x80; ch = cfont.font[fontChar.dataPtr++]; } if ((ch & mask) != 0) { // visible pixel bufPos = ((j + fontChar.adjYOffset) * (char_width + 1)) + (fontChar.xOffset + i); // bufY + bufX color_line[bufPos] = _fg; } mask >>= 1; } } // send to display in one transaction TFT_EPD_disp_select(); if (tft_active_mode != TFT_MODE_EVE) wait_trans_finish(1); TFT_EPD_send_data(x, y, x + char_width, y + cfont.y_size - 1, len, color_line, 1); TFT_EPD_disp_deselect(); if (tft_active_mode != TFT_MODE_EVE) free(color_line); return char_width; } } int cx, cy; if (!font_transparent) _fillRect(x, y, char_width + 1, cfont.y_size, _bg); // draw Glyph uint8_t mask = 0x80; TFT_EPD_disp_select(); for (j = 0; j < fontChar.height; j++) { for (i = 0; i < fontChar.width; i++) { if (((i + (j * fontChar.width)) % 8) == 0) { mask = 0x80; ch = cfont.font[fontChar.dataPtr++]; } if ((ch & mask) != 0) { cx = (uint16_t)(x + fontChar.xOffset + i); cy = (uint16_t)(y + j + fontChar.adjYOffset); TFT_EPD_drawPixe(cx, cy, _fg, 0); } mask >>= 1; } } TFT_EPD_disp_deselect(); return char_width; } // non-rotated fixed width character // ---------------------------------------------- static void printChar(uint8_t c, int x, int y) { uint8_t i, j, ch, fz, mask; uint16_t k, temp, cx, cy, len; // fz = bytes per char row fz = cfont.x_size / 8; if (cfont.x_size % 8) fz++; // get character position in buffer temp = ((c - cfont.offset) * ((fz)*cfont.y_size)) + 4; if ((font_buffered_char) && (!font_transparent)) { // === buffer Glyph data for faster sending === len = cfont.x_size * cfont.y_size; color_t *color_line = malloc(len * 3); if (color_line) { // fill with background color for (int n = 0; n < len; n++) { color_line[n] = _bg; } // set character pixels to foreground color for (j = 0; j < cfont.y_size; j++) { for (k = 0; k < fz; k++) { ch = cfont.font[temp + k]; mask = 0x80; for (i = 0; i < 8; i++) { if ((ch & mask) != 0) color_line[(j * cfont.x_size) + (i + (k * 8))] = _fg; mask >>= 1; } } temp += (fz); } // send to display in one transaction TFT_EPD_disp_select(); if (tft_active_mode != TFT_MODE_EVE) wait_trans_finish(1); TFT_EPD_send_data(x, y, x + cfont.x_size - 1, y + cfont.y_size - 1, len, color_line, 1); TFT_EPD_disp_deselect(); if (tft_active_mode != TFT_MODE_EVE) free(color_line); return; } } if (!font_transparent) _fillRect(x, y, cfont.x_size, cfont.y_size, _bg); TFT_EPD_disp_select(); for (j = 0; j < cfont.y_size; j++) { for (k = 0; k < fz; k++) { ch = cfont.font[temp + k]; mask = 0x80; for (i = 0; i < 8; i++) { if ((ch & mask) != 0) { cx = (uint16_t)(x + i + (k * 8)); cy = (uint16_t)(y + j); TFT_EPD_drawPixe(cx, cy, _fg, 0); } mask >>= 1; } } temp += (fz); } TFT_EPD_disp_deselect(); } // print rotated proportional character // character is already in fontChar // --------------------------------------------------- static int rotatePropChar(int x, int y, int offset) { uint8_t ch = 0; double radian = font_rotate * DEG_TO_RAD; float cos_radian = cos(radian); float sin_radian = sin(radian); uint8_t mask = 0x80; TFT_EPD_disp_select(); for (int j = 0; j < fontChar.height; j++) { for (int i = 0; i < fontChar.width; i++) { if (((i + (j * fontChar.width)) % 8) == 0) { mask = 0x80; ch = cfont.font[fontChar.dataPtr++]; } int newX = (int)(x + (((offset + i) * cos_radian) - ((j + fontChar.adjYOffset) * sin_radian))); int newY = (int)(y + (((j + fontChar.adjYOffset) * cos_radian) + ((offset + i) * sin_radian))); if ((ch & mask) != 0) TFT_EPD_drawPixe(newX, newY, _fg, 0); else if (!font_transparent) TFT_EPD_drawPixe(newX, newY, _bg, 0); mask >>= 1; } } TFT_EPD_disp_deselect(); return fontChar.xDelta + 1; } // rotated fixed width character // -------------------------------------------------------- static void rotateChar(uint8_t c, int x, int y, int pos) { uint8_t i, j, ch, fz, mask; uint16_t temp; int newx, newy; double radian = font_rotate * 0.0175; float cos_radian = cos(radian); float sin_radian = sin(radian); int zz; if (cfont.x_size < 8) fz = cfont.x_size; else fz = cfont.x_size / 8; temp = ((c - cfont.offset) * ((fz)*cfont.y_size)) + 4; TFT_EPD_disp_select(); for (j = 0; j < cfont.y_size; j++) { for (zz = 0; zz < (fz); zz++) { ch = cfont.font[temp + zz]; mask = 0x80; for (i = 0; i < 8; i++) { newx = (int)(x + (((i + (zz * 8) + (pos * cfont.x_size)) * cos_radian) - ((j)*sin_radian))); newy = (int)(y + (((j)*cos_radian) + ((i + (zz * 8) + (pos * cfont.x_size)) * sin_radian))); if ((ch & mask) != 0) TFT_EPD_drawPixe(newx, newy, _fg, 0); else if (!font_transparent) TFT_EPD_drawPixe(newx, newy, _bg, 0); mask >>= 1; } } temp += (fz); } TFT_EPD_disp_deselect(); // calculate x,y for the next char TFT_X = (int)(x + ((pos + 1) * cfont.x_size * cos_radian)); TFT_Y = (int)(y + ((pos + 1) * cfont.x_size * sin_radian)); } // ---------------------- static int _7seg_width() { return (2 * (2 * cfont.y_size + 1)) + cfont.x_size; } // ----------------------- static int _7seg_height() { return (3 * (2 * cfont.y_size + 1)) + (2 * cfont.x_size); } // Returns the string width in pixels. // Useful for positions strings on the screen. // =============================== int TFT_getStringWidth(char *str) { int strWidth = 0; if (cfont.bitmap == 2) strWidth = ((_7seg_width() + 2) * strlen(str)) - 2; // 7-segment font else if (cfont.x_size != 0) strWidth = strlen(str) * cfont.x_size; // fixed width font else { // calculate the width of the string of proportional characters char *tempStrptr = str; while (*tempStrptr != 0) { if (getCharPtr(*tempStrptr++)) { strWidth += (((fontChar.width > fontChar.xDelta) ? fontChar.width : fontChar.xDelta) + 1); } } strWidth--; } return strWidth; } // =============================================== void TFT_clearStringRect(int x, int y, char *str) { int w = TFT_getStringWidth(str); int h = TFT_getfontheight(); TFT_fillRect(x + dispWin.x1, y + dispWin.y1, w, h, _bg); } // ============================================================================== /** * bit-encoded bar position of all digits' bcd segments * * 6 * +-----+ * 3 | . | 2 * +--5--+ * 1 | . | 0 * +--.--+ * 4 */ static const uint16_t font_bcd[] = { 0x200, // 0010 0000 0000 // - 0x080, // 0000 1000 0000 // . 0x06C, // 0100 0110 1100 // / (degree sign) 0x05f, // 0000 0101 1111, // 0 0x005, // 0000 0000 0101, // 1 0x076, // 0000 0111 0110, // 2 0x075, // 0000 0111 0101, // 3 0x02d, // 0000 0010 1101, // 4 0x079, // 0000 0111 1001, // 5 0x07b, // 0000 0111 1011, // 6 0x045, // 0000 0100 0101, // 7 0x07f, // 0000 0111 1111, // 8 0x07d, // 0000 0111 1101 // 9 0x900, // 1001 0000 0000 // : 0x000 // 0000 0000 0000 // ; (space) }; // ----------------------------------------------------------------------------------------------- static void barVert(int16_t x, int16_t y, int16_t w, int16_t l, color_t color, color_t outline) { _fillTriangle(x + 1, y + 2 * w, x + w, y + w + 1, x + 2 * w - 1, y + 2 * w, color); _fillTriangle(x + 1, y + 2 * w + l + 1, x + w, y + 3 * w + l, x + 2 * w - 1, y + 2 * w + l + 1, color); _fillRect(x, y + 2 * w + 1, 2 * w + 1, l, color); if (cfont.offset) { _drawTriangle(x + 1, y + 2 * w, x + w, y + w + 1, x + 2 * w - 1, y + 2 * w, outline); _drawTriangle(x + 1, y + 2 * w + l + 1, x + w, y + 3 * w + l, x + 2 * w - 1, y + 2 * w + l + 1, outline); _drawRect(x, y + 2 * w + 1, 2 * w + 1, l, outline); } } // ---------------------------------------------------------------------------------------------- static void barHor(int16_t x, int16_t y, int16_t w, int16_t l, color_t color, color_t outline) { _fillTriangle(x + 2 * w, y + 2 * w - 1, x + w + 1, y + w, x + 2 * w, y + 1, color); _fillTriangle(x + 2 * w + l + 1, y + 2 * w - 1, x + 3 * w + l, y + w, x + 2 * w + l + 1, y + 1, color); _fillRect(x + 2 * w + 1, y, l, 2 * w + 1, color); if (cfont.offset) { _drawTriangle(x + 2 * w, y + 2 * w - 1, x + w + 1, y + w, x + 2 * w, y + 1, outline); _drawTriangle(x + 2 * w + l + 1, y + 2 * w - 1, x + 3 * w + l, y + w, x + 2 * w + l + 1, y + 1, outline); _drawRect(x + 2 * w + 1, y, l, 2 * w + 1, outline); } } // -------------------------------------------------------------------------------------------- static void _draw7seg(int16_t x, int16_t y, int8_t num, int16_t w, int16_t l, color_t color) { /* TODO: clipping */ uint8_t nnum = num; if (num == 0x20) nnum = 0x3B; // to clear the space character if ((nnum < 0x2D) || (nnum > 0x3B)) return; int16_t c = font_bcd[nnum - 0x2D]; int16_t d = 2 * w + l + 1; // === Clear unused segments === if (!(c & 0x001)) barVert(x + d, y + d, w, l, _bg, _bg); if (!(c & 0x002)) barVert(x, y + d, w, l, _bg, _bg); if (!(c & 0x004)) barVert(x + d, y, w, l, _bg, _bg); if (!(c & 0x008)) barVert(x, y, w, l, _bg, _bg); if (!(c & 0x010)) barHor(x, y + 2 * d, w, l, _bg, _bg); if (!(c & 0x020)) barHor(x, y + d, w, l, _bg, _bg); if (!(c & 0x040)) barHor(x, y, w, l, _bg, _bg); if (!(c & 0x080)) { // low point _fillRect(x + (d / 2), y + 2 * d, 2 * w + 1, 2 * w + 1, _bg); if (cfont.offset) _drawRect(x + (d / 2), y + 2 * d, 2 * w + 1, 2 * w + 1, _bg); } if (!(c & 0x100)) { // down middle point _fillRect(x + (d / 2), y + d + 2 * w + 1, 2 * w + 1, l / 2, _bg); if (cfont.offset) _drawRect(x + (d / 2), y + d + 2 * w + 1, 2 * w + 1, l / 2, _bg); } if (!(c & 0x800)) { // up middle point _fillRect(x + (d / 2), y + (2 * w) + 1 + (l / 2), 2 * w + 1, l / 2, _bg); if (cfont.offset) _drawRect(x + (d / 2), y + (2 * w) + 1 + (l / 2), 2 * w + 1, l / 2, _bg); } if (!(c & 0x200)) { // middle, minus _fillRect(x + 2 * w + 1, y + d, l, 2 * w + 1, _bg); if (cfont.offset) _drawRect(x + 2 * w + 1, y + d, l, 2 * w + 1, _bg); } if (c == 0) return; // === Draw used segments === if (c & 0x001) barVert(x + d, y + d, w, l, color, cfont.color); // down right if (c & 0x002) barVert(x, y + d, w, l, color, cfont.color); // down left if (c & 0x004) barVert(x + d, y, w, l, color, cfont.color); // up right if (c & 0x008) barVert(x, y, w, l, color, cfont.color); // up left if (c & 0x010) barHor(x, y + 2 * d, w, l, color, cfont.color); // down if (c & 0x020) barHor(x, y + d, w, l, color, cfont.color); // middle if (c & 0x040) barHor(x, y, w, l, color, cfont.color); // up if (c & 0x080) { // low point _fillRect(x + (d / 2), y + 2 * d, 2 * w + 1, 2 * w + 1, color); if (cfont.offset) _drawRect(x + (d / 2), y + 2 * d, 2 * w + 1, 2 * w + 1, cfont.color); } if (c & 0x100) { // down middle point _fillRect(x + (d / 2), y + d + 2 * w + 1, 2 * w + 1, l / 2, color); if (cfont.offset) _drawRect(x + (d / 2), y + d + 2 * w + 1, 2 * w + 1, l / 2, cfont.color); } if (c & 0x800) { // up middle point _fillRect(x + (d / 2), y + (2 * w) + 1 + (l / 2), 2 * w + 1, l / 2, color); if (cfont.offset) _drawRect(x + (d / 2), y + (2 * w) + 1 + (l / 2), 2 * w + 1, l / 2, cfont.color); } if (c & 0x200) { // middle, minus _fillRect(x + 2 * w + 1, y + d, l, 2 * w + 1, color); if (cfont.offset) _drawRect(x + 2 * w + 1, y + d, l, 2 * w + 1, cfont.color); } } // ============================================================================== void TFT_print(char *st, int x, int y) { int stl, i, tmpw, tmph, fh; uint8_t ch; if (cfont.bitmap == 0) return; // wrong font selected // ** Rotated strings cannot be aligned if ((font_rotate != 0) && ((x <= CENTER) || (y <= CENTER))) return; if ((x < LASTX) || (font_rotate == 0)) TFT_OFFSET = 0; if ((x >= LASTX) && (x < LASTY)) x = TFT_X + (x - LASTX); else if (x > CENTER) x += dispWin.x1; if (y >= LASTY) y = TFT_Y + (y - LASTY); else if (y > CENTER) y += dispWin.y1; // ** Get number of characters in string to print stl = strlen(st); // ** Calculate CENTER, RIGHT or BOTTOM position tmpw = TFT_getStringWidth(st); // string width in pixels fh = cfont.y_size; // font height if ((cfont.x_size != 0) && (cfont.bitmap == 2)) { // 7-segment font fh = (3 * (2 * cfont.y_size + 1)) + (2 * cfont.x_size); // 7-seg character height } if (x == RIGHT) x = dispWin.x2 - tmpw + dispWin.x1; else if (x == CENTER) x = (((dispWin.x2 - dispWin.x1 + 1) - tmpw) / 2) + dispWin.x1; if (y == BOTTOM) y = dispWin.y2 - fh + dispWin.y1; else if (y == CENTER) y = (((dispWin.y2 - dispWin.y1 + 1) - (fh / 2)) / 2) + dispWin.y1; if (x < dispWin.x1) x = dispWin.x1; if (y < dispWin.y1) y = dispWin.y1; if ((x > dispWin.x2) || (y > dispWin.y2)) return; TFT_X = x; TFT_Y = y; // ** Adjust y position tmph = cfont.y_size; // font height // for non-proportional fonts, char width is the same for all chars tmpw = cfont.x_size; if (cfont.x_size != 0) { if (cfont.bitmap == 2) { // 7-segment font tmpw = _7seg_width(); // character width tmph = _7seg_height(); // character height } } else { TFT_OFFSET = 0; // fixed font; offset not needed } if ((TFT_Y + tmph - 1) > dispWin.y2) return; int offset = TFT_OFFSET; for (i = 0; i < stl; i++) { ch = st[i]; // get string character if (ch == 0x0D) { // === '\r', erase to eol ==== if ((!font_transparent) && (font_rotate == 0)) _fillRect(TFT_X, TFT_Y, dispWin.x2 + 1 - TFT_X, tmph, _bg); } else if (ch == 0x0A) { // ==== '\n', new line ==== if (cfont.bitmap == 1) { TFT_Y += tmph + font_line_space; if (TFT_Y > (dispWin.y2 - tmph)) break; TFT_X = dispWin.x1; } } else { // ==== other characters ==== if (cfont.x_size == 0) { // for proportional font get character data to 'fontChar' if (getCharPtr(ch)) tmpw = fontChar.xDelta; else continue; } // check if character can be displayed in the current line if ((TFT_X + tmpw) > (dispWin.x2)) { if (text_wrap == 0) break; TFT_Y += tmph + font_line_space; if (TFT_Y > (dispWin.y2 - tmph)) break; TFT_X = dispWin.x1; } // Let's print the character if (cfont.x_size == 0) { // == proportional font if (font_rotate == 0) TFT_X += printProportionalChar(TFT_X, TFT_Y) + 1; else { // rotated proportional font offset += rotatePropChar(x, y, offset); TFT_OFFSET = offset; } } else { if (cfont.bitmap == 1) { // == fixed font if ((ch < cfont.offset) || ((ch - cfont.offset) > cfont.numchars)) ch = cfont.offset; if (font_rotate == 0) { printChar(ch, TFT_X, TFT_Y); TFT_X += tmpw; } else rotateChar(ch, x, y, i); } else if (cfont.bitmap == 2) { // == 7-segment font == _draw7seg(TFT_X, TFT_Y, ch, cfont.y_size, cfont.x_size, _fg); TFT_X += (tmpw + 2); } } } } } // void TFT_print_unicode(uint16_t *unicode, uint16_t len, int x, int y) { // int i, tmpw = 0, tmph = 0; // uint16_t ch; // if ((x < LASTX) || (font_rotate == 0)) TFT_OFFSET = 0; // if ((x >= LASTX) && (x < LASTY)) x = TFT_X + (x-LASTX); // else if (x > CENTER) x += dispWin.x1; // if (y >= LASTY) y = TFT_Y + (y-LASTY); // else if (y > CENTER) y += dispWin.y1; // TFT_X = x; // TFT_Y = y; // tmph = gfx_font->yAdvance; // if ((TFT_Y + tmph - 1) > dispWin.y2) return; // uint16_t offset = 0; // for (i = 0; i < len; i++) { // ch = unicode[i]; // if (ch == 0x0D) { // === '\r', erase to eol ==== // _fillRect(TFT_X, TFT_Y, dispWin.x2+1-TFT_X, tmph, _bg); // } else if (ch == 0x0A) { // TFT_Y += tmph + font_line_space; // if (TFT_Y > (dispWin.y2-tmph)) break; // TFT_X = dispWin.x1; // } else { // // if (ch <= '~') { // // if (getCharPtr(ch)) tmpw = fontChar.xDelta; // // } else { // tmpw = GetUnicodeWidth(ch); // if (tmpw == 0) continue; // // } // if ((TFT_X+tmpw) > (dispWin.x2)) { // if (text_wrap == 0) break; // TFT_Y += tmph + font_line_space; // if (TFT_Y > (dispWin.y2-tmph)) break; // TFT_X = dispWin.x1; // } // if(font_rotate == 0) { // TFT_X += unicode_printProportionalChar(ch, TFT_X, TFT_Y) + 1; // } else { // offset += unicode_rotateProChar(ch, x, y, offset); // } // } // } // } // ================ Service functions ========================================== // Change the screen rotation. // Input: m new rotation value (0 to 3) // ================================= void TFT_setRotation(uint8_t rot) { if (rot > 3) { uint8_t madctl = (rot & 0xF8); // for testing, manually set MADCTL register if (TFT_EPD_disp_select() == ESP_OK) { disp_spi_transfer_cmd_data(TFT_MADCTL, &madctl, 1); TFT_EPD_disp_deselect(); } } else { orientation = rot; _tft_setRotation(rot); } dispWin.x1 = 0; dispWin.y1 = 0; dispWin.x2 = _width - 1; dispWin.y2 = _height - 1; TFT_fillScreen(_bg); } // Send the command to invert all of the colors. // Input: i 0 to disable inversion; non-zero to enable inversion // ========================================== void TFT_invertDisplay(const uint8_t mode) { if (mode == INVERT_ON) disp_spi_transfer_cmd(TFT_INVONN); else disp_spi_transfer_cmd(TFT_INVOFF); } // Select gamma curve // Input: gamma = 0~3 // ================================== void TFT_setGammaCurve(uint8_t gm) { uint8_t gamma_curve = 1 << (gm & 0x03); disp_spi_transfer_cmd_data(TFT_CMD_GAMMASET, &gamma_curve, 1); } // =========================================================== color_t HSBtoRGB(float _hue, float _sat, float _brightness) { float red = 0.0; float green = 0.0; float blue = 0.0; if (_sat == 0.0) { red = _brightness; green = _brightness; blue = _brightness; } else { if (_hue == 360.0) { _hue = 0; } int slice = (int)(_hue / 60.0); float hue_frac = (_hue / 60.0) - slice; float aa = _brightness * (1.0 - _sat); float bb = _brightness * (1.0 - _sat * hue_frac); float cc = _brightness * (1.0 - _sat * (1.0 - hue_frac)); switch (slice) { case 0: red = _brightness; green = cc; blue = aa; break; case 1: red = bb; green = _brightness; blue = aa; break; case 2: red = aa; green = _brightness; blue = cc; break; case 3: red = aa; green = bb; blue = _brightness; break; case 4: red = cc; green = aa; blue = _brightness; break; case 5: red = _brightness; green = aa; blue = bb; break; default: red = 0.0; green = 0.0; blue = 0.0; break; } } color_t color; color.r = ((uint8_t)(red * 255.0)) & 0xFC; color.g = ((uint8_t)(green * 255.0)) & 0xFC; color.b = ((uint8_t)(blue * 255.0)) & 0xFC; return color; } // ===================================================================== void TFT_setclipwin(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) { dispWin.x1 = x1; dispWin.y1 = y1; dispWin.x2 = x2; dispWin.y2 = y2; if (dispWin.x2 >= _width) dispWin.x2 = _width - 1; if (dispWin.y2 >= _height) dispWin.y2 = _height - 1; if (dispWin.x1 > dispWin.x2) dispWin.x1 = dispWin.x2; if (dispWin.y1 > dispWin.y2) dispWin.y1 = dispWin.y2; } // ===================== void TFT_resetclipwin() { dispWin.x2 = _width - 1; dispWin.y2 = _height - 1; dispWin.x1 = 0; dispWin.y1 = 0; } // ========================================================================== void set_7seg_font_atrib(uint8_t l, uint8_t w, int outline, color_t color) { if (cfont.bitmap != 2) return; if (l < 6) l = 6; if (l > 40) l = 40; if (w < 1) w = 1; if (w > (l / 2)) w = l / 2; if (w > 12) w = 12; cfont.x_size = l; cfont.y_size = w; cfont.offset = outline; cfont.color = color; } // ========================================== int TFT_getfontsize(int *width, int *height) { if (cfont.bitmap == 1) { if (cfont.x_size != 0) *width = cfont.x_size; // fixed width font else *width = cfont.max_x_size; // proportional font *height = cfont.y_size; } else if (cfont.bitmap == 2) { // 7-segment font *width = _7seg_width(); *height = _7seg_height(); } else { *width = 0; *height = 0; return 0; } return 1; } // ===================== int TFT_getfontheight() { if (cfont.bitmap == 1) return cfont.y_size; // Bitmap font else if (cfont.bitmap == 2) return _7seg_height(); // 7-segment font return 0; } // ==================== void TFT_saveClipWin() { dispWinTemp.x1 = dispWin.x1; dispWinTemp.y1 = dispWin.y1; dispWinTemp.x2 = dispWin.x2; dispWinTemp.y2 = dispWin.y2; } // ======================= void TFT_restoreClipWin() { dispWin.x1 = dispWinTemp.x1; dispWin.y1 = dispWinTemp.y1; dispWin.x2 = dispWinTemp.x2; dispWin.y2 = dispWinTemp.y2; } // ================ JPG SUPPORT ================================================ // User defined device identifier typedef struct { // lfs2_t* fs; // lfs2_file_t fhndl; // File handler for input function int x; // image top left point X position int y; // image top left point Y position uint8_t *membuff; // memory buffer containing the image uint32_t bufsize; // size of the memory buffer uint32_t bufptr; // memory buffer current position color_t *linbuf[2]; // memory buffer used for display output uint8_t linbuf_idx; } JPGIODEV; #if 0 // User defined call-back function to input JPEG data from file // --------------------- static UINT tjd_input ( JDEC* jd, // Decompression object BYTE* buff, // Pointer to the read buffer (NULL:skip) UINT nd // Number of bytes to read/skip from input stream ) { UINT rb = 0; // Device identifier for the session (5th argument of jd_prepare function) JPGIODEV *dev = (JPGIODEV*)jd->device; if (buff) { // Read nd bytes from the input strem rb = lfs2_file_read(dev->fs, &dev->fhndl, buff, nd); return rb; // Returns actual number of bytes read } else { // Remove nd bytes from the input stream if(lfs2_file_seek(dev->fs, &dev->fhndl, nd, LFS2_SEEK_CUR) < 0) return 0; else return nd; } } #endif // User defined call-back function to input JPEG data from memory buffer // ------------------------- static UINT tjd_buf_input( JDEC *jd, // Decompression object BYTE *buff, // Pointer to the read buffer (NULL:skip) UINT nd // Number of bytes to read/skip from input stream ) { // Device identifier for the session (5th argument of jd_prepare function) JPGIODEV *dev = (JPGIODEV *)jd->device; if (!dev->membuff) return 0; if (dev->bufptr >= (dev->bufsize + 2)) return 0; // end of stream if ((dev->bufptr + nd) > (dev->bufsize + 2)) nd = (dev->bufsize + 2) - dev->bufptr; if (buff) { // Read nd bytes from the input strem memcpy(buff, dev->membuff + dev->bufptr, nd); dev->bufptr += nd; return nd; // Returns number of bytes read } else { // Remove nd bytes from the input stream dev->bufptr += nd; return nd; } } // User defined call-back function to output RGB bitmap to display device // ---------------------- static UINT tjd_output( JDEC *jd, // Decompression object of current session void *bitmap, // Bitmap data to be output JRECT *rect // Rectangular region to output ) { // Device identifier for the session (5th argument of jd_prepare function) JPGIODEV *dev = (JPGIODEV *)jd->device; // ** Put the rectangular into the display device ** int x; int y; int dleft, dtop, dright, dbottom; BYTE *src = (BYTE *)bitmap; int left = rect->left + dev->x; int top = rect->top + dev->y; int right = rect->right + dev->x; int bottom = rect->bottom + dev->y; if ((left > dispWin.x2) || (top > dispWin.y2)) return 1; // out of screen area, return if ((right < dispWin.x1) || (bottom < dispWin.y1)) return 1; // out of screen area, return if (left < dispWin.x1) dleft = dispWin.x1; else dleft = left; if (top < dispWin.y1) dtop = dispWin.y1; else dtop = top; if (right > dispWin.x2) dright = dispWin.x2; else dright = right; if (bottom > dispWin.y2) dbottom = dispWin.y2; else dbottom = bottom; if ((dleft > dispWin.x2) || (dtop > dispWin.y2)) return 1; // out of screen area, return if ((dright < dispWin.x1) || (dbottom < dispWin.y1)) return 1; // out of screen area, return uint32_t len = ((dright - dleft + 1) * (dbottom - dtop + 1)); // calculate length of data if ((len > 0) && (len <= JPG_IMAGE_LINE_BUF_SIZE)) { uint8_t *dest = (uint8_t *)(dev->linbuf[dev->linbuf_idx]); for (y = top; y <= bottom; y++) { for (x = left; x <= right; x++) { // Clip to display area if ((x >= dleft) && (y >= dtop) && (x <= dright) && (y <= dbottom)) { *dest++ = (*src++) & 0xFC; *dest++ = (*src++) & 0xFC; *dest++ = (*src++) & 0xFC; } else src += 3; // skip } } if (image_trans) { send_data(dleft, dtop, dright, dbottom, len, dev->linbuf[dev->linbuf_idx], 0); } else { disp_select(); send_data(dleft, dtop, dright, dbottom, len, dev->linbuf[dev->linbuf_idx], 0); wait_trans_finish(1); disp_deselect(); } dev->linbuf_idx = ((dev->linbuf_idx + 1) & 1); } else { if (image_trans) wait_trans_finish(1); mp_printf(&mp_plat_print, "Data size error: %d jpg: (%d,%d,%d,%d) disp: (%d,%d,%d,%d)\r\n", len, left, top, right, bottom, dleft, dtop, dright, dbottom); return 0; // stop decompression } return 1; // Continue to decompression } // tft.jpgimage(X, Y, scale, file_name, buf, size] // X & Y can be < 0 ! // ================================================================================== void TFT_jpg_image(int x, int y, uint8_t scale, char *fname, uint8_t *buf, int size) { JPGIODEV dev; char *work = NULL; // Pointer to the working buffer (must be 4-byte aligned) UINT sz_work = 3800; // Size of the working buffer (must be power of 2) JDEC jd; // Decompression object (70 bytes) JRESULT rc = JDR_OK; // struct lfs2_info fno; // enum lfs2_error res; // lfs2_t *fs = NULL; const char *fullname; // struct lfs2_file_config cfg; // memset(&cfg, 0, sizeof(struct lfs2_file_config)); // memset(&dev.fhndl, 0, sizeof(lfs2_file_t)); dev.linbuf[0] = NULL; dev.linbuf[1] = NULL; dev.linbuf_idx = 0; // dev.fhndl = NULL; if (fname == NULL) { // image from buffer dev.membuff = buf; dev.bufsize = size; dev.bufptr = 0; image_trans = true; } else { #if 0 fs = lookup_path(fname, &fullname); dev.fs = fs; // image from file dev.membuff = NULL; dev.bufsize = 0; dev.bufptr = 0; res = lfs2_stat(fs, fullname, &fno); if (res != LFS2_ERR_OK) { if (image_debug) mp_printf(&mp_plat_print, "File error: %ss\r\n", strerror(errno)); goto exit; } cfg.buffer = calloc(fs->cfg->cache_size, sizeof(uint8_t)); res = lfs2_file_opencfg(fs, &dev.fhndl, fullname, LFS2_O_RDONLY, &cfg); if (res != LFS2_ERR_OK) { if (image_debug) mp_printf(&mp_plat_print, "Error opening file: %s\r\n", strerror(errno)); goto exit; } image_trans = strstr(fname, "/sd") ? false : true; #endif } // Check if the image file is on sdcard if (scale > 3) scale = 3; work = malloc(sz_work); if (work) { if (dev.membuff) rc = jd_prepare(&jd, tjd_buf_input, (void *)work, sz_work, &dev); #if 0 else rc = jd_prepare(&jd, tjd_input, (void *)work, sz_work, &dev); #endif if (rc == JDR_OK) { if (x == CENTER) x = ((dispWin.x2 - dispWin.x1 + 1 - (int)(jd.width >> scale)) / 2) + dispWin.x1; else if (x == RIGHT) x = dispWin.x2 + 1 - (int)(jd.width >> scale); if (y == CENTER) y = ((dispWin.y2 - dispWin.y1 + 1 - (int)(jd.height >> scale)) / 2) + dispWin.y1; else if (y == BOTTOM) y = dispWin.y2 + 1 - (int)(jd.height >> scale); if (x < ((dispWin.x2 - 1) * -1)) x = (dispWin.x2 - 1) * -1; if (y < ((dispWin.y2 - 1)) * -1) y = (dispWin.y2 - 1) * -1; if (x > (dispWin.x2 - 1)) x = dispWin.x2 - 1; if (y > (dispWin.y2 - 1)) y = dispWin.y2 - 1; dev.x = x; dev.y = y; if (tft_active_mode != TFT_MODE_EPD) { dev.linbuf[0] = malloc(JPG_IMAGE_LINE_BUF_SIZE * 3); if (dev.linbuf[0] == NULL) { if (image_debug) mp_printf(&mp_plat_print, "Error allocating line buffer #0\r\n"); goto exit; } dev.linbuf[1] = malloc(JPG_IMAGE_LINE_BUF_SIZE * 3); if (dev.linbuf[1] == NULL) { if (image_debug) mp_printf(&mp_plat_print, "Error allocating line buffer #1\r\n"); goto exit; } } // Start to decode the JPEG file if (image_trans) TFT_EPD_disp_select(); rc = jd_decomp(&jd, tjd_output, scale); if (image_trans) { wait_trans_finish(1); TFT_EPD_disp_deselect(); } if (rc != JDR_OK) { if (image_debug) mp_printf(&mp_plat_print, "jpg decompression error %d\r\n", rc); } if (image_debug) mp_printf(&mp_plat_print, "Jpg size: %dx%d, position; %d,%d, scale: %d, bytes used: %d\r\n", jd.width, jd.height, x, y, scale, jd.sz_pool); image_width = jd.width; image_hight = jd.height; } else { if (image_debug) mp_printf(&mp_plat_print, "jpg prepare error %d\r\n", rc); } } else { if (image_debug) mp_printf(&mp_plat_print, "work buffer allocation error\r\n"); } exit: if (work) free(work); // free work buffer if (dev.linbuf[0]) free(dev.linbuf[0]); if (dev.linbuf[1]) free(dev.linbuf[1]); #if 0 if (fs != NULL && res == LFS2_ERR_OK) { lfs2_file_close(fs, &dev.fhndl); // close input file free(cfg.buffer); } #endif } #if 0 // ==================================================================================== int TFT_bmp_image(int x, int y, uint8_t scale, char *fname, uint8_t *imgbuf, int size) { lfs2_file_t *fhndl = NULL; lfs2_t *fs = NULL; struct lfs2_info fno; const char *fullname; enum lfs2_error res; struct lfs2_file_config cfg; UINT i, err=0; int img_xsize, img_ysize, img_xstart, img_xlen, img_ystart, img_ylen; int img_pos, img_pix_pos, scan_lines, rd_len; uint8_t tmpc; uint16_t wtemp; uint32_t temp; int disp_xstart, disp_xend, disp_ystart, disp_yend; uint8_t buf[56]; char err_buf[64]; uint8_t *line_buf[2] = {NULL, NULL}; uint8_t lb_idx = 0; uint8_t *scale_buf = NULL; uint8_t scale_pix; uint16_t co[3] = {0, 0, 0}; // RGB sum uint8_t npix; memset(&cfg, 0, sizeof(cfg)); if (scale > 7) scale = 7; scale_pix = scale+1; // scale factor ( 1~8 ) if (fname) { fs = lookup_path(fname, &fullname); // * File name is given, reading image from file res = lfs2_stat(fs, fullname, &fno); fhndl = (lfs2_file_t *)calloc(1, sizeof(lfs2_file_t)); if (res != LFS2_ERR_OK) { sprintf(err_buf, "opening file"); err = -1; goto exit; } size = fno.size; cfg.buffer = calloc(fs->cfg->cache_size, sizeof(uint8_t)); res = lfs2_file_opencfg(fs, fhndl, fullname, LFS2_O_RDONLY, &cfg); if (res != LFS2_ERR_OK) { sprintf(err_buf, "opening file"); err = res; goto exit; } i = lfs2_file_read(fs, fhndl, buf, 54); image_trans = strstr(fname, "/sd") ? false : true; } else { // * Reading image from buffer if ((imgbuf) && (size > 54)) { memcpy(buf, imgbuf, 54); i = 54; } else { i = 0; } image_trans = true; } // Check if the image file is on sdcard sprintf(err_buf, "reading header"); if (i != 54) { err = -3; goto exit; } // ** Check image header and get image properties if ((buf[0] != 'B') || (buf[1] != 'M')) {err=-4; goto exit;} // accept only images with 'BM' id memcpy(&temp, buf+2, 4); // file size if (temp != size) {err=-5; goto exit;} memcpy(&img_pos, buf+10, 4); // start of pixel data memcpy(&temp, buf+14, 4); // BMP header size if (temp != 40) {err=-6; goto exit;} memcpy(&wtemp, buf+26, 2); // the number of color planes if (wtemp != 1) {err=-7; goto exit;} memcpy(&wtemp, buf+28, 2); // the number of bits per pixel if (wtemp != 24) {err=-8; goto exit;} memcpy(&temp, buf+30, 4); // the compression method being used if (temp != 0) {err=-9; goto exit;} memcpy(&img_xsize, buf+18, 4); // the bitmap width in pixels memcpy(&img_ysize, buf+22, 4); // the bitmap height in pixels // * scale image dimensions img_xlen = img_xsize / scale_pix; // image display horizontal size img_ylen = img_ysize / scale_pix; // image display vertical size if (x == CENTER) x = ((dispWin.x2 - dispWin.x1 + 1 - img_xlen) / 2) + dispWin.x1; else if (x == RIGHT) x = dispWin.x2 + 1 - img_xlen; if (y == CENTER) y = ((dispWin.y2 - dispWin.y1 + 1 - img_ylen) / 2) + dispWin.y1; else if (y == BOTTOM) y = dispWin.y2 + 1 - img_ylen; if ((x < ((dispWin.x2 + 1) * -1)) || (x > (dispWin.x2 + 1)) || (y < ((dispWin.y2 + 1) * -1)) || (y > (dispWin.y2 + 1))) { sprintf(err_buf, "out of display area (%d,%d", x, y); err = -10; goto exit; } // ** set display and image areas if (x < dispWin.x1) { disp_xstart = dispWin.x1; img_xstart = -x; // image pixel line X offset img_xlen += x; } else { disp_xstart = x; img_xstart = 0; } if (y < dispWin.y1) { disp_ystart = dispWin.y1; img_ystart = -y; // image pixel line Y offset img_ylen += y; } else { disp_ystart = y; img_ystart = 0; } disp_xend = disp_xstart + img_xlen - 1; disp_yend = disp_ystart + img_ylen - 1; if (disp_xend > dispWin.x2) { disp_xend = dispWin.x2; img_xlen = disp_xend - disp_xstart + 1; } if (disp_yend > dispWin.y2) { disp_yend = dispWin.y2; img_ylen = disp_yend - disp_ystart + 1; } if ((img_xlen < 8) || (img_ylen < 8) || (img_xstart >= (img_xsize-2)) || ((img_ysize - img_ystart) < 2)) { sprintf(err_buf, "image too small"); err = -11; goto exit; } // ** Allocate memory for 2 lines of image pixels line_buf[0] = malloc(img_xsize*3); if (line_buf[0] == NULL) { sprintf(err_buf, "allocating line buffer #1"); err=-12; goto exit; } line_buf[1] = malloc(img_xsize*3); if (line_buf[1] == NULL) { sprintf(err_buf, "allocating line buffer #2"); err=-13; goto exit; } if (scale) { // Allocate memory for scale buffer rd_len = img_xlen * 3 * scale_pix; scale_buf = malloc(rd_len*scale_pix); if (scale_buf == NULL) { sprintf(err_buf, "allocating scale buffer"); err=-14; goto exit; } } else { rd_len = img_xlen * 3; } // ** ***************************************************** ** // ** BMP images are stored in file from LAST to FIRST line ** // ** ***************************************************** ** /* Used variables: img_xsize horizontal image size in pixels img_ysize number of image lines img_xlen image display horizontal scaled size in pixels img_ylen image display vertical scaled size in pixels img_xstart first pixel in line to be displayed img_ystart first image line to be displayed img_xlen number of pixels in image line to be displayed, starting with 'img_xstart' img_ylen number of lines in image to be displayed, starting with 'img_ystart' rd_len length of color data which are read from image line in bytes */ // Set position in image to the first color data (beginning of the LAST line) img_pos += (img_ystart * (img_xsize*3)); if (fhndl) { if (fs != NULL && lfs2_file_seek(fs, fhndl, img_pos, LFS2_SEEK_SET) != img_pos) { sprintf(err_buf, "file seek at %d", img_pos); err = -15; goto exit; } } if (image_debug) mp_printf(&mp_plat_print, "BMP: image size: (%d,%d) scale: %d disp size: (%d,%d) img xofs: %d img yofs: %d at: %d,%d; line buf: 2* %d scale buf: %d\r\n", img_xsize, img_ysize, scale_pix, img_xlen, img_ylen, img_xstart, img_ystart, disp_xstart, disp_ystart, img_xsize*3, ((scale) ? (rd_len*scale_pix) : 0)); image_width = img_xlen; image_hight = img_ylen; // * Select the display if (image_trans) disp_select(); while ((disp_yend >= disp_ystart) && ((img_pos + (img_xsize*3)) <= size)) { if (img_pos > size) { sprintf(err_buf, "EOF reached: %d > %d", img_pos, size); err = -16; goto exit1; } if (scale == 0) { // Read the line of color data into color buffer if (fhndl) { i = lfs2_file_read(fs, fhndl, line_buf[lb_idx], img_xsize*3); if (i != (img_xsize*3)) { sprintf(err_buf, "file read at %d (%d<>%d)", img_pos, i, img_xsize*3); err = -16; goto exit1; } } else memcpy(line_buf[lb_idx], imgbuf+img_pos, img_xsize*3); if (img_xstart > 0) memmove(line_buf[lb_idx], line_buf[lb_idx]+(img_xstart*3), rd_len); // Convert colors BGR-888 (BMP) -> RGB-888 (DISPLAY) === for (i=0; i < rd_len; i += 3) { tmpc = line_buf[lb_idx][i+2] & 0xfc; // save R line_buf[lb_idx][i+2] = line_buf[lb_idx][i] & 0xfc; // B -> R line_buf[lb_idx][i] = tmpc; // R -> B line_buf[lb_idx][i+1] &= 0xfc; // G } img_pos += (img_xsize*3); else { // scale image, read 'scale_pix' lines and find the average color for (scan_lines=0; scan_lines<scale_pix; scan_lines++) { if (img_pos > size) break; if (fhndl) { i = lfs2_file_read(fs, fhndl, line_buf[lb_idx], img_xsize*3); if (i != (img_xsize*3)) { sprintf(err_buf, "file read at %d (%d<>%d)", img_pos, i, img_xsize*3); err = -17; goto exit1; } } else memcpy(line_buf[lb_idx], imgbuf+img_pos, img_xsize*3); img_pos += (img_xsize*3); // copy only data which are displayed to scale buffer memcpy(scale_buf + (rd_len * scan_lines), line_buf[lb_idx]+img_xstart, rd_len); } // Populate display line buffer for (int n=0;n<(img_xlen*3);n += 3) { memset(co, 0, sizeof(co)); // initialize color sum npix = 0; // initialize number of pixels in scale rectangle // sum all pixels in scale rectangle for (int sc_line=0; sc_line<scan_lines; sc_line++) { // Get colors position in scale buffer img_pix_pos = (rd_len * sc_line) + (n * scale_pix); for (int sc_col=0; sc_col<scale_pix; sc_col++) { co[0] += scale_buf[img_pix_pos]; co[1] += scale_buf[img_pix_pos + 1]; co[2] += scale_buf[img_pix_pos + 2]; npix++; } } // Place the average in display buffer, convert BGR-888 (BMP) -> RGB-888 (DISPLAY) line_buf[lb_idx][n+2] = (uint8_t)(co[0] / npix); // B line_buf[lb_idx][n+1] = (uint8_t)(co[1] / npix); // G line_buf[lb_idx][n] = (uint8_t)(co[2] / npix); // R } } if (image_trans) { wait_trans_finish(1); send_data(disp_xstart, disp_yend, disp_xend, disp_yend, img_xlen, (color_t *)line_buf[lb_idx], 0); } else { disp_select(); send_data(disp_xstart, disp_yend, disp_xend, disp_yend, img_xlen, (color_t *)line_buf[lb_idx], 0); wait_trans_finish(1); disp_deselect(); } lb_idx = (lb_idx + 1) & 1; // change buffer disp_yend--; } wait_trans_finish(1); err = 0; exit1: if (image_trans) disp_deselect(); exit: if (scale_buf) free(scale_buf); if (line_buf[0]) free(line_buf[0]); if (line_buf[1]) free(line_buf[1]); if (fhndl) { lfs2_file_close(fs, fhndl); free(fhndl); free(cfg.buffer); } if ((err) && (image_debug)) mp_printf(&mp_plat_print, "Error: %d [%s]\r\n", err, err_buf); return err; } #include "pngle/pngle.h" #define jpgColor(c) \ (((uint16_t)(((uint8_t *)(c))[0] & 0xF8) << 8) | \ ((uint16_t)(((uint8_t *)(c))[1] & 0xFC) << 3) | \ ((((uint8_t *)(c))[2] & 0xF8) >> 3)) typedef struct _png_draw_params { uint16_t x; uint16_t y; uint16_t maxWidth; uint16_t maxHeight; uint16_t offX; uint16_t offY; double scale; uint8_t alphaThreshold; } png_file_decoder_t; static void pngle_draw_callback(pngle_t *pngle, uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint8_t rgba[4]) { color_t _color; png_file_decoder_t *p = (png_file_decoder_t *)pngle_get_user_data(pngle); uint16_t color = jpgColor(rgba); // XXX: It's PNG ;) if (x < p->offX || y < p->offY) return ; x -= p->offX; y -= p->offY; // An interlaced file with alpha channel causes disaster, so use 1 here for simplicity w = 1; h = 1; if (p->scale != 1) { x = (uint32_t)ceil(x * p->scale); y = (uint32_t)ceil(y * p->scale); w = (uint32_t)ceil(w * p->scale); h = (uint32_t)ceil(h * p->scale); } if (x >= p->maxWidth || y >= p->maxHeight) return ; if (x + w >= p->maxWidth) w = p->maxWidth - x; if (y + h >= p->maxHeight) h = p->maxHeight - y; x += p->x; y += p->y; _color.r = (color & 0xF800) >> 8; _color.g = (color & 0x07E0) >> 3; _color.b = (color & 0x001F) << 3; if (rgba[3] >= p->alphaThreshold) { // TFT_fillRect(x, y, w, h, _color); TFT_drawPixel(x, y, _color, 1); } } int TFT_png_image(int x, int y, uint8_t scale, char *fname, uint8_t *imgbuf, int size) { lfs2_file_t *fhndl = NULL; lfs2_t *fs = NULL; struct lfs2_info fno; const char *fullname; enum lfs2_error res; struct lfs2_file_config cfg; UINT err=0; char err_buf[64]; // uint8_t buf[56]; memset(&cfg, 0, sizeof(cfg)); if (scale > 7) scale = 7; scale = scale + 1; // scale factor ( 1~8 ) pngle_t *pngle = pngle_new(); png_file_decoder_t png; png.x = x; png.y = y; png.offX = 0; png.offY = 0; png.scale = scale; png.alphaThreshold = 127; png.maxHeight = dispWin.y2; png.maxWidth = dispWin.x2; pngle_set_user_data(pngle, &png); pngle_set_draw_callback(pngle, pngle_draw_callback); if (fname) { fs = lookup_path(fname, &fullname); // * File name is given, reading image from file res = lfs2_stat(fs, fullname, &fno); fhndl = (lfs2_file_t *)calloc(1, sizeof(lfs2_file_t)); if (res != LFS2_ERR_OK) { sprintf(err_buf, "opening file"); err = -1; goto exit; } size = fno.size; cfg.buffer = calloc(fs->cfg->cache_size, sizeof(uint8_t)); res = lfs2_file_opencfg(fs, fhndl, fullname, LFS2_O_RDONLY, &cfg); if (res != LFS2_ERR_OK) { sprintf(err_buf, "opening file"); err = res; goto exit; } uint8_t buf[1024]; int remain = 0; int len; while ((len = lfs2_file_read(fs, fhndl, buf + remain, sizeof(buf) - remain)) > 0) { // i = lfs2_file_read(fs, fhndl, buf, 54); int fed = pngle_feed(pngle, buf, remain + len); if (fed < 0) { printf("[pngle error] %s", pngle_error(pngle)); break; } remain = remain + len - fed; // printf("remain: %d\r\n", remain); if (remain > 0) memmove(buf, buf + fed, remain); } image_width = pngle_get_width(pngle); image_hight = pngle_get_height(pngle); } else { int fed = pngle_feed(pngle, imgbuf, size); if (fed < 0) { printf("[pngle error] %s", pngle_error(pngle)); } image_width = pngle_get_width(pngle); image_hight = pngle_get_height(pngle); } exit: pngle_destroy(pngle); if (fhndl) { lfs2_file_close(fs, fhndl); free(fhndl); free(cfg.buffer); } return err; } #endif // ============= Touch panel functions ========================================= // ------------------------------------------------------- static int tp_get_data_xpt2046(uint8_t type, int samples) { if (ts_spi->handle == NULL) return 0; int n, result, val = 0; uint32_t i = 0; uint32_t vbuf[18]; uint32_t minval, maxval, dif; if (samples < 3) samples = 1; if (samples > 18) samples = 18; // one dummy read result = touch_get_data(type); // read data while (i < 10) { minval = 5000; maxval = 0; // get values for (n = 0; n < samples; n++) { result = touch_get_data(type); if (result < 0) break; vbuf[n] = result; if (result < minval) minval = result; if (result > maxval) maxval = result; } if (result < 0) break; dif = maxval - minval; if (dif < 40) break; i++; } if (result < 0) return -1; if (samples > 2) { // remove one min value for (n = 0; n < samples; n++) { if (vbuf[n] == minval) { vbuf[n] = 5000; break; } } // remove one max value for (n = 0; n < samples; n++) { if (vbuf[n] == maxval) { vbuf[n] = 5000; break; } } for (n = 0; n < samples; n++) { if (vbuf[n] < 5000) val += vbuf[n]; } val /= (samples - 2); } else val = vbuf[0]; return val; } // ----------------------------------------------- static int TFT_read_touch_xpt2046(int *x, int *y) { int res = 0, result = -1; if (spi_device_select(ts_spi, 0) != ESP_OK) return 0; result = tp_get_data_xpt2046(0xB0, 3); // Z; pressure; touch detect if (result <= 50) goto exit; // touch panel pressed result = tp_get_data_xpt2046(0xD0, 10); if (result < 0) goto exit; *x = result; result = tp_get_data_xpt2046(0x90, 10); if (result < 0) goto exit; *y = result; res = 1; exit: spi_device_deselect(ts_spi); return res; } // ============================================= int TFT_read_touch(int *x, int *y, uint8_t raw) { *x = 0; *y = 0; if (ts_spi->handle == NULL) return 0; if (tft_touch_type == TOUCH_TYPE_NONE) return 0; int result = -1; int X = 0, Y = 0; if (tft_touch_type == TOUCH_TYPE_XPT2046) { if (tp_calx == 0) { // Set default calibration constants tp_calx = TP_CALX_XPT2046; tp_caly = TP_CALY_XPT2046; } result = TFT_read_touch_xpt2046(&X, &Y); if (result == 0) return 0; } else if (tft_touch_type == TOUCH_TYPE_STMPE610) { if (tp_calx == 0) { // Set default calibration constants tp_calx = TP_CALX_STMPE610; tp_caly = TP_CALY_STMPE610; } uint16_t Xx, Yy, Z = 0; result = stmpe610_get_touch(&Xx, &Yy, &Z); if (result == 0) return 0; X = Xx; Y = Yy; } else return 0; if (raw) { *x = X; *y = Y; return 1; } // Calibrate the result int tmp; int xleft = (tp_calx >> 16) & 0x3FFF; int xright = tp_calx & 0x3FFF; int ytop = (tp_caly >> 16) & 0x3FFF; int ybottom = tp_caly & 0x3FFF; if (((xright - xleft) <= 0) || ((ybottom - ytop) <= 0)) return 0; if (tft_touch_type == TOUCH_TYPE_XPT2046) { int width = _width; int height = _height; X = ((X - xleft) * height) / (xright - xleft); Y = ((Y - ytop) * width) / (ybottom - ytop); if (X < 0) X = 0; if (X > height - 1) X = height - 1; if (Y < 0) Y = 0; if (Y > width - 1) Y = width - 1; switch (orientation) { case PORTRAIT: tmp = X; X = width - Y - 1; Y = tmp; break; case PORTRAIT_FLIP: tmp = X; X = Y; Y = height - tmp - 1; break; case LANDSCAPE_FLIP: X = height - X - 1; Y = width - Y - 1; break; } } else if (tft_touch_type == TOUCH_TYPE_STMPE610) { int width = _width; int height = _height; if (_width > _height) { width = _height; height = _width; } X = ((X - xleft) * width) / (xright - xleft); Y = ((Y - ytop) * height) / (ybottom - ytop); if (X < 0) X = 0; if (X > width - 1) X = width - 1; if (Y < 0) Y = 0; if (Y > height - 1) Y = height - 1; switch (orientation) { case PORTRAIT_FLIP: X = width - X - 1; Y = height - Y - 1; break; case LANDSCAPE: tmp = X; X = Y; Y = width - tmp - 1; break; case LANDSCAPE_FLIP: tmp = X; X = height - Y - 1; Y = tmp; break; } } *x = X; *y = Y; return 1; } extern color_t *trans_cline; void TFT_pushBitMap(int x, int y, int w, int h, uint8_t *bitmap, color_t color, color_t bg_color) { int _x = x; int _y = y; int _w = w; if ((x >= dispWin.x2) || (y > dispWin.y2)) return; if (x < dispWin.x1) { w -= (dispWin.x1 - x); x = dispWin.x1; } if (y < dispWin.y1) { h -= (dispWin.y1 - y); y = dispWin.y1; } if (w < 0) w = 0; if (h < 0) h = 0; if ((x + w) > (dispWin.x2 + 1)) w = dispWin.x2 - x + 1; if ((y + h) > (dispWin.y2 + 1)) h = dispWin.y2 - y + 1; if (w == 0) w = 1; if (h == 0) h = 1; uint32_t len = w * h; wait_trans_finish(1); if (disp_select() != ESP_OK) return; disp_spi_transfer_addrwin(x, x + w - 1, y, y + h - 1); disp_spi_transfer_cmd(TFT_RAMWR); // --- more than 512 bits, no repeat: use DMA transfer --- if (trans_cline) return; uint32_t buf_colors; int buf_bytes; uint32_t send_len = 0; uint16_t send_num; color_t *trans_cline_cache = NULL; color_t *trans_cline_swap = trans_cline_cache; uint8_t *trans_cline16 = NULL; // Prepare color buffer of maximum 2 lines buf_colors = _width * 5; buf_bytes = buf_colors * (bits_per_color / 8); trans_cline_cache = heap_caps_malloc(buf_bytes + 3, MALLOC_CAP_DMA); trans_cline = heap_caps_malloc(buf_bytes + 3, MALLOC_CAP_DMA); if ((trans_cline == NULL) || (trans_cline_cache == NULL)) return; send_num = len / buf_colors; int now_x = 0; uint32_t now_pixel = (x - _x) + (y - _y) * _w; uint16_t _color16 = color16(color); uint16_t _color16_bg = color16(bg_color); while (send_len < len) { if (send_num == 0) { buf_colors = len % buf_colors; buf_bytes = buf_colors * (bits_per_color / 8); } trans_cline16 = (uint8_t *)trans_cline; for (uint16_t i = 0; i < buf_colors; i++) { if (bitmap[(now_pixel) >> 3] & (0x80 >> ((now_pixel)&0x07))) { if (bits_per_color == 16) { trans_cline16[i * 2] = (uint8_t)(_color16 >> 8); trans_cline16[(i * 2) + 1] = (uint8_t)(_color16 & 0xFF); } else { trans_cline[i] = color; } } else { if (bits_per_color == 16) { trans_cline16[i * 2] = (uint8_t)(_color16_bg >> 8); trans_cline16[(i * 2) + 1] = (uint8_t)(_color16_bg & 0xFF); } else { trans_cline[i] = bg_color; } } now_x += 1; now_pixel += 1; if (now_x == w) { now_pixel += _w - w; now_x = 0; } } wait_trans_finish(0); _dma_send(disp_spi, (uint8_t *)trans_cline, buf_bytes); trans_cline_swap = trans_cline_cache; trans_cline_cache = trans_cline; trans_cline = trans_cline_swap; send_len += buf_colors; send_num -= 1; } free(trans_cline); trans_cline = trans_cline_cache; disp_deselect(); } // IRAM_ATTR int32_t GetUnicodeRangeIndex(uint32_t code) { // int32_t index = -1; // uint32_t low = 0; // uint32_t high = gfx_font->range_num; // uint32_t middle; // if((code >= gfx_font->range[0].start) && (code <= gfx_font->range[0].end)) { // return code - gfx_font->range[0].start + gfx_font->range[0].base; // } // while (low <= high) { // middle = (high + low) >> 1; // if (code > gfx_font->range[middle].end) { // low = middle + 1; // } else if (code < gfx_font->range[middle].start) { // high = middle - 1; // } else if((code >= gfx_font->range[middle].start) && (code <= gfx_font->range[middle].end)) { // index = code - gfx_font->range[middle].start + gfx_font->range[middle].base; // break; // } // } // return index; // } // int16_t GetUnicodeWidth(uint32_t code) { // int32_t index = GetUnicodeRangeIndex(code); // if (index >= 0) { // return gfx_font->glyph[index].xAdvance; // } else { // return gfx_font->glyph[NOTFOUNDINDEX].xAdvance; // } // return 0; // } // int unicode_printProportionalChar(uint32_t code, int x, int y) { // uint8_t ch = 0; // int index = GetUnicodeRangeIndex(code); // if (index == -1) { // index = 10; // // return 0; // } // GFXglyph* glyph = &gfx_font->glyph[index]; // int unicode_offset = glyph->bitmapOffset; // int i, j; // int len, bufPos, char_width; // char_width = glyph->xAdvance; // // === buffer Glyph data for faster sending === // len = (char_width + 1) * gfx_font->yAdvance; // color_t *color_line = calloc(len*3, sizeof(uint8_t)); // int32_t y_offset = gfx_font->yAdvance + glyph->yOffset; // // 0x39, 18, 16, 20, 1, -19 // if (color_line) { // for (uint16_t n = 0; n < len; n++) { // // fill with background color // color_line[n] = _bg; // } // // set character pixels to foreground color // uint8_t mask = 0x80; // for (j=0; j < glyph->height; j++) { // for (i=0; i < glyph->width; i++) { // if (((i + (j*glyph->width)) % 8) == 0) { // mask = 0x80; // ch = gfx_font->bitmap[unicode_offset++]; // } // if ((ch & mask) != 0) { // // visible pixel // bufPos = (j + y_offset) * (char_width + 1) + glyph->xOffset + i; // bufY + bufX // color_line[bufPos] = _fg; // } // mask >>= 1; // } // } // // send to display in one transaction // wait_trans_finish(1); // disp_select(); // send_data(x, y, x+char_width, y+gfx_font->yAdvance-1, len, color_line, 1); // disp_deselect(); // free(color_line); // return char_width; // } // return 0; // } // int unicode_rotateProChar(uint32_t code, int x, int y, uint16_t offset) { // uint8_t ch = 0; // double radian = font_rotate * DEG_TO_RAD; // float cos_radian = cos(radian); // float sin_radian = sin(radian); // int index = GetUnicodeRangeIndex(code); // if (index == -1) { // index = 10; // } // GFXglyph* glyph = &gfx_font->glyph[index]; // int unicode_offset = glyph->bitmapOffset; // int i, j; // int char_width; // char_width = glyph->xAdvance; // // === buffer Glyph data for faster sending === // int32_t y_offset = gfx_font->yAdvance + glyph->yOffset; // TFT_EPD_disp_select(); // // 0x39, 18, 16, 20, 1, -19 // uint8_t mask = 0x80; // for (j=0; j < glyph->height; j++) { // for (i=0; i < glyph->width; i++) { // if (((i + (j*glyph->width)) % 8) == 0) { // mask = 0x80; // ch = gfx_font->bitmap[unicode_offset++]; // } // int newX = (int)(x + (((glyph->xOffset + i + offset) * cos_radian) - ((j+y_offset)*sin_radian))); // int newY = (int)(y + (((j+y_offset) * cos_radian) + ((offset + glyph->xOffset + i) * sin_radian))); // if ((ch & mask) != 0) TFT_EPD_drawPixe(newX, newY, _fg, 0); // else if (!font_transparent) TFT_EPD_drawPixe(newX, newY, _bg, 0); // mask >>= 1; // } // } // TFT_EPD_disp_deselect(); // return char_width; // }
YifuLiu/AliOS-Things
components/py_engine/modules/display/esp32/tft/tft.c
C
apache-2.0
122,870
/* * This file is part of the MicroPython ESP32 project, https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo * * The MIT License (MIT) * * Copyright (c) 2018 LoBo (https://github.com/loboris) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ /* * High level TFT functions * Author: LoBo 02/2018, https://github/loboris * */ #ifndef _TFT_H_ #define _TFT_H_ #include "sdkconfig.h" #include <stdlib.h> #include "tftspi.h" #include "py/obj.h" #define TFT_MODE_TFT 0 #define TFT_MODE_EPD 1 #define TFT_MODE_EVE 2 #define TFT_MODE_SPRITE 3 typedef struct { uint16_t x1; uint16_t y1; uint16_t x2; uint16_t y2; } dispWin_t; typedef struct { uint8_t *font; uint8_t x_size; uint8_t y_size; uint8_t offset; uint16_t numchars; uint16_t size; uint8_t max_x_size; uint8_t bitmap; color_t color; } Font; typedef struct _tft_eve_obj_t { mp_obj_base_t base; uint32_t addr; uint32_t size; uint16_t width; uint16_t height; uint16_t rowsize; uint8_t type; uint8_t byte_per_pixel; uint8_t prev_tft_mode; uint8_t loaded; } tft_eve_obj_t; //========================================================================================== // ==== Global variables =================================================================== //========================================================================================== extern uint8_t orientation; // current screen orientation extern uint16_t font_rotate; // current font font_rotate angle (0~395) extern uint8_t font_transparent; // if not 0 draw fonts transparent extern uint8_t font_forceFixed; // if not zero force drawing proportional fonts with fixed width extern uint8_t font_buffered_char; extern uint8_t font_line_space; // additional spacing between text lines; added to font height extern uint8_t text_wrap; // if not 0 wrap long text to the new line, else clip extern color_t _fg; // current foreground color for fonts extern color_t _bg; // current background for non transparent fonts extern uint8_t font_now; extern dispWin_t dispWin; // display clip window extern float _angleOffset; // angle offset for arc, polygon and line by angle functions extern uint8_t image_debug; // print debug messages during image decode if set to 1 extern Font cfont; // Current font structure extern int TFT_X; // X position of the next character after TFT_print() function extern int TFT_Y; // Y position of the next character after TFT_print() function extern uint16_t image_width; extern uint16_t image_hight; extern uint32_t tp_calx; // touch screen X calibration constant extern uint32_t tp_caly; // touch screen Y calibration constant extern uint8_t tft_active_mode; // used tft driver mode (TFT, EPD or EVE) // ========================================================================================= // Buffer is created during jpeg decode for sending data // Total size of the buffer is 2 * (JPG_IMAGE_LINE_BUF_SIZE * 3) // The size must be multiple of 256 bytes !! #define JPG_IMAGE_LINE_BUF_SIZE 512 // --- Constants for ellipse function --- #define TFT_ELLIPSE_UPPER_RIGHT 0x01 #define TFT_ELLIPSE_UPPER_LEFT 0x02 #define TFT_ELLIPSE_LOWER_LEFT 0x04 #define TFT_ELLIPSE_LOWER_RIGHT 0x08 // Constants for Arc function // number representing the maximum angle (e.g. if 100, then if you pass in start=0 and end=50, you get a half circle) // this can be changed with setArcParams function at runtime #define DEFAULT_ARC_ANGLE_MAX 360 // rotational offset in degrees defining position of value 0 (-90 will put it at the top of circle) // this can be changed with setAngleOffset function at runtime #define DEFAULT_ANGLE_OFFSET -90 #define PI 3.14159265359 #define MIN_POLIGON_SIDES 3 #define MAX_POLIGON_SIDES 60 // === Color names constants === extern const color_t TFT_BLACK; extern const color_t TFT_NAVY; extern const color_t TFT_DARKGREEN; extern const color_t TFT_DARKCYAN; extern const color_t TFT_MAROON; extern const color_t TFT_PURPLE; extern const color_t TFT_OLIVE; extern const color_t TFT_LIGHTGREY; extern const color_t TFT_DARKGREY; extern const color_t TFT_BLUE; extern const color_t TFT_GREEN; extern const color_t TFT_CYAN; extern const color_t TFT_RED; extern const color_t TFT_MAGENTA; extern const color_t TFT_YELLOW; extern const color_t TFT_WHITE; extern const color_t TFT_ORANGE; extern const color_t TFT_GREENYELLOW; extern const color_t TFT_PINK; #define iTFT_BLACK 0 #define iTFT_NAVY 128 #define iTFT_DARKGREEN 32768 #define iTFT_DARKCYAN 32896 #define iTFT_MAROON 8388608 #define iTFT_PURPLE 8388736 #define iTFT_OLIVE 8421376 #define iTFT_LIGHTGREY 12632256 #define iTFT_DARKGREY 8421504 #define iTFT_BLUE 255 #define iTFT_GREEN 65280 #define iTFT_CYAN 65535 #define iTFT_RED 16515072 #define iTFT_MAGENTA 16515327 #define iTFT_YELLOW 16579584 #define iTFT_WHITE 16579836 #define iTFT_ORANGE 16557056 #define iTFT_GREENYELLOW 11336748 #define iTFT_PINK 16564426 // === Color invert constants === #define INVERT_ON 1 #define INVERT_OFF 0 // === Special coordinates constants === #define CENTER -9003 #define RIGHT -9004 #define BOTTOM -9004 #define LASTX 7000 #define LASTY 8000 // === Embedded fonts constants === #define DEFAULT_FONT 0 #define DEJAVU18_FONT 1 #define DEJAVU24_FONT 2 #define UBUNTU16_FONT 3 #define COMIC24_FONT 4 #define MINYA24_FONT 5 #define TOONEY32_FONT 6 #define SMALL_FONT 7 #define DEF_SMALL_FONT 8 #define FONT_7SEG 9 #define USER_FONT 10 // font will be read from file #define DEJAVU40_FONT 11 #define DEJAVU56_FONT 12 #define DEJAVU72_FONT 13 #define ARIAL12_FONT 14 #define ARIAL16_FONT 15 // #define UNICODE_FONT 16 #define IMAGE_TYPE_JPG 1 #define IMAGE_TYPE_BMP 2 #define IMAGE_TYPE_PNG 3 // ===== PUBLIC FUNCTIONS ========================================================================= /* * Draw pixel at given x,y coordinates * * Params: * x: horizontal position * y: vertical position * color: pixel color * sel: if not 0 activate CS before and deactivat after sending pixel data to display * when sending multiple pixels it is faster to activate the CS first, * send all pixels an deactivate CS after all pixela was sent */ //------------------------------------------------------------------- void TFT_drawPixel(int16_t x, int16_t y, color_t color, uint8_t sel); /* * Read pixel color value from display GRAM at given x,y coordinates * * Params: * x: horizontal position * y: vertical position * * Returns: * pixel color at x,y */ //------------------------------------------ color_t TFT_readPixel(int16_t x, int16_t y); /* * Draw vertical line at given x,y coordinates * * Params: * x: horizontal start position * y: vertical start position * h: line height in pixels * color: line color */ //--------------------------------------------------------------------- void TFT_drawFastVLine(int16_t x, int16_t y, int16_t h, color_t color); /* * Draw horizontal line at given x,y coordinates * * Params: * x: horizontal start position * y: vertical start position * w: line width in pixels * color: line color */ //--------------------------------------------------------------------- void TFT_drawFastHLine(int16_t x, int16_t y, int16_t w, color_t color); /* * Draw line on screen * * Params: * x0: horizontal start position * y0: vertical start position * x1: horizontal end position * y1: vertical end position * color: line color */ //------------------------------------------------------------------------------- void TFT_drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, color_t color); /* * Draw line on screen from (x,y) point at given angle * Line drawing angle starts at lower right quadrant of the screen and is offseted by * '_angleOffset' global variable (default: -90 degrees) * * Params: * x: horizontal start position * y: vertical start position * start: start offset from (x,y) * len: length of the line * angle: line angle in degrees * color: line color */ //----------------------------------------------------------------------------------------------------------- void TFT_drawLineByAngle(uint16_t x, uint16_t y, uint16_t start, uint16_t len, uint16_t angle, color_t color); /* * Fill given rectangular screen region with color * * Params: * x: horizontal rect start position * y: vertical rect start position * w: rectangle width * h: rectangle height * color: fill color */ //--------------------------------------------------------------------------- void TFT_fillRect(int16_t x, int16_t y, int16_t w, int16_t h, color_t color); /* * Draw rectangle on screen * * Params: * x: horizontal rect start position * y: vertical rect start position * w: rectangle width * h: rectangle height * color: rect line color */ //------------------------------------------------------------------------------ void TFT_drawRect(uint16_t x1,uint16_t y1,uint16_t w,uint16_t h, color_t color); /* * Draw rectangle with rounded corners on screen * * Params: * x: horizontal rect start position * y: vertical rect start position * w: rectangle width * h: rectangle height * r: corner radius * color: rectangle color */ //---------------------------------------------------------------------------------------------- void TFT_drawRoundRect(int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t r, color_t color); /* * Fill given rectangular screen region with rounded corners with color * * Params: * x: horizontal rect start position * y: vertical rect start position * w: rectangle width * h: rectangle height * r: corner radius * color: fill color */ //---------------------------------------------------------------------------------------------- void TFT_fillRoundRect(int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t r, color_t color); /* * Fill the whole screen with color * * Params: * color: fill color */ //-------------------------------- void TFT_fillScreen(color_t color); /* * Fill the current clip window with color * * Params: * color: fill color */ //--------------------------------- void TFT_fillWindow(color_t color); /* * Draw triangle on screen * * Params: * x0: first triangle point x position * y0: first triangle point y position * x0: second triangle point x position * y0: second triangle point y position * x0: third triangle point x position * y0: third triangle point y position * color: triangle color */ //----------------------------------------------------------------------------------------------------------------- void TFT_drawTriangle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, color_t color); /* * Fill triangular screen region with color * * Params: * x0: first triangle point x position * y0: first triangle point y position * x0: second triangle point x position * y0: second triangle point y position * x0: third triangle point x position * y0: third triangle point y position * color: fill color */ //----------------------------------------------------------------------------------------------------------------- void TFT_fillTriangle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, color_t color); /* * Draw circle on screen * * Params: * x: circle center x position * y: circle center x position * r: circle radius * color: circle color */ //------------------------------------------------------------------- void TFT_drawCircle(int16_t x, int16_t y, int radius, color_t color); /* * Fill circle on screen with color * * Params: * x: circle center x position * y: circle center x position * r: circle radius * color: circle fill color */ //------------------------------------------------------------------- void TFT_fillCircle(int16_t x, int16_t y, int radius, color_t color); //------------------------------------------------------------------- void TFT_drawSwitchBtn(int16_t x, int16_t y, int width, int hight, color_t color, color_t switch_color, uint8_t state); /* * Draw ellipse on screen * * Params: * x0: ellipse center x position * y0: ellipse center x position * rx: ellipse horizontal radius * ry: ellipse vertical radius * option: drawing options, multiple options can be combined 1 (TFT_ELLIPSE_UPPER_RIGHT) draw upper right corner 2 (TFT_ELLIPSE_UPPER_LEFT) draw upper left corner 4 (TFT_ELLIPSE_LOWER_LEFT) draw lower left corner 8 (TFT_ELLIPSE_LOWER_RIGHT) draw lower right corner to draw the whole ellipse use option value 15 (1 | 2 | 4 | 8) * * color: circle color */ //------------------------------------------------------------------------------------------------------ void TFT_drawEllipse(uint16_t x0, uint16_t y0, uint16_t rx, uint16_t ry, color_t color, uint8_t option); /* * Fill elliptical region on screen * * Params: * x0: ellipse center x position * y0: ellipse center x position * rx: ellipse horizontal radius * ry: ellipse vertical radius * option: drawing options, multiple options can be combined 1 (TFT_ELLIPSE_UPPER_RIGHT) fill upper right corner 2 (TFT_ELLIPSE_UPPER_LEFT) fill upper left corner 4 (TFT_ELLIPSE_LOWER_LEFT) fill lower left corner 8 (TFT_ELLIPSE_LOWER_RIGHT) fill lower right corner to fill the whole ellipse use option value 15 (1 | 2 | 4 | 8) * * color: fill color */ //------------------------------------------------------------------------------------------------------ void TFT_fillEllipse(uint16_t x0, uint16_t y0, uint16_t rx, uint16_t ry, color_t color, uint8_t option); /* * Draw circle arc on screen * Arc drawing angle starts at lower right quadrant of the screen and is offseted by * '_angleOffset' global variable (default: -90 degrees) * * Params: * cx: arc center X position * cy: arc center Y position * th: thickness of the drawn arc * ry: arc vertical radius * start: arc start angle in degrees * end: arc end angle in degrees * color: arc outline color * fillcolor: arc fill color */ //---------------------------------------------------------------------------------------------------------------------------- void TFT_drawArc(uint16_t cx, uint16_t cy, uint16_t r, uint16_t th, float start, float end, color_t color, color_t fillcolor); /* * Draw polygon on screen * * Params: * cx: polygon center X position * cy: arc center Y position * sides: number of polygon sides; MAX_POLIGON_SIDES ~ MAX_POLIGON_SIDES (3 ~ 60) * diameter: diameter of the circle inside which the polygon is drawn * color: polygon outline color * fill: polygon fill color; if same as color, polygon is not filled * deg: polygon rotation angle; 0 ~ 360 * th: thickness of the polygon outline */ //-------------------------------------------------------------------------------------------------------------- void TFT_drawPolygon(int cx, int cy, int sides, int diameter, color_t color, color_t fill, int deg, uint8_t th); //-------------------------------------------------------------------------------------- //void TFT_drawStar(int cx, int cy, int diameter, color_t color, bool fill, float factor); /* * Set the font used for writing the text to display. * * ------------------------------------------------------------------------------------ * For 7 segment font only characters 0,1,2,3,4,5,6,7,8,9, . , - , : , / are available. * Character ‘/‘ draws the degree sign. * ------------------------------------------------------------------------------------ * * Params: * font: font number; use defined font names * font_file: pointer to font file name; NULL for embeded fonts */ //---------------------------------------------------- void TFT_setFont(uint8_t font, const char *font_file); /* * Returns current font height & width in pixels. * * Params: * width: pointer to returned font width * height: pointer to returned font height */ //------------------------------------------- int TFT_getfontsize(int *width, int* height); /* * Returns current font height in pixels. * */ //---------------------- int TFT_getfontheight(); /* * Write text to display. * * Rotation of the displayed text depends on 'font_rotate' variable (0~360) * if 'font_transparent' variable is set to 1, no background pixels will be printed * * If the text does not fit the screen width it will be clipped (if text_wrap=0), * or continued on next line (if text_wrap=1) * * Two special characters are allowed in strings: * ‘\r’ CR (0x0D), clears the display to EOL * ‘\n’ LF (ox0A), continues to the new line, x=0 * * Params: * st: pointer to null terminated string to be printed * x: horizontal position of the upper left point in pixels * Special values can be entered: * CENTER, centers the text * RIGHT, right justifies the text * LASTX, continues from last X position; offset can be used: LASTX+n * y: vertical position of the upper left point in pixels * Special values can be entered: * CENTER, centers the text * BOTTOM, bottom justifies the text * LASTY, continues from last Y position; offset can be used: LASTY+n * */ //------------------------------------- void TFT_print(char *st, int x, int y); void TFT_print_unicode(uint16_t *unicode, uint16_t len, int x, int y); /* * Set atributes for 7 segment vector font * == 7 segment font must be the current font to this function to have effect == * * Params: * l: 6~40; distance between bars in pixels * w: 1~12, max l/2; bar width in pixels * outline: draw font outline if set to 1 * color: font outline color, only used if outline=1 * */ //------------------------------------------------------------------------- void set_7seg_font_atrib(uint8_t l, uint8_t w, int outline, color_t color); /* * Sets the clipping area coordinates. * All writing to screen is clipped to that area. * Starting x & y in all functions will be adjusted to the clipping area. * * Params: * x1,y1: upper left point of the clipping area * x2,y2: bottom right point of the clipping area * */ //---------------------------------------------------------------------- void TFT_setclipwin(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2); /* * Resets the clipping area to full screen (0,0),(_wodth,_height) * */ //---------------------- void TFT_resetclipwin(); /* * Save current clipping area to temporary variable * */ //--------------------- void TFT_saveClipWin(); /* * Restore current clipping area from temporary variable * */ //------------------------ void TFT_restoreClipWin(); /* * Set the screen rotation * Also resets the clip window and clears the screen with current background color * * Params: * rot: 0~3; screen rotation; use defined rotation constants: * PORTRAIT, LANDSCAPE, PORTRAIT_FLIP, LANDSCAPE_FLIP * */ //-------------------------------- void TFT_setRotation(uint8_t rot); /* * Set inverted/normal colors * * Params: * mode: 0 or 1; use defined constants: INVERT_ON or INVERT_OFF * */ //----------------------------------------- void TFT_invertDisplay(const uint8_t mode); /* * Select gamma curve * Params: * gamma: gama curve, values 0~3 */ //================================= void TFT_setGammaCurve(uint8_t gm); /* * Compare two color structures * Returns 0 if equal, 1 if not equal * * Params: * c1, c2: colors to be compared */ //--------------------------------------------- int TFT_compare_colors(color_t c1, color_t c2); /* * returns the string width in pixels. * Useful for positions strings on the screen. */ //-------------------------------- int TFT_getStringWidth(char* str); /* * Fills the rectangle occupied by string with current background color */ //------------------------------------------------ void TFT_clearStringRect(int x, int y, char *str); /* * Converts the components of a color, as specified by the HSB model, * to an equivalent set of values for the default RGB model. * The color structure that is returned by HSBtoRGB encodes the value of a color as R, G & B component * * Params: * _hue: float; any number, the floor of this number is subtracted from it to create a fraction between 0 and 1. * This fractional number is then multiplied by 360 to produce the hue angle in the HSB color model. * _sat: float; 0 ~ 1.0 * _brightness: float; 0 ~ 1.0 * */ //---------------------------------------------------------- color_t HSBtoRGB(float _hue, float _sat, float _brightness); /* * Decodes and displays JPG image * Limits: * Baseline only. Progressive and Lossless JPEG format are not supported. * Image size: Up to 65520 x 65520 pixels * Color space: YCbCr three components only. Gray scale image is not supported. * Sampling factor: 4:4:4, 4:2:2 or 4:2:0. * * Params: * x: image left position; constants CENTER & RIGHT can be used; negative value is accepted * y: image top position; constants CENTER & BOTTOM can be used; negative value is accepted * scale: image scale factor: 0~3; if scale>0, image is scaled by factor 1/(2^scale) (1/2, 1/4 or 1/8) * fname: pointer to the name of the file from which the image will be read * if set to NULL, image will be read from memory buffer pointed to by 'buf' * buf: pointer to the memory buffer from which the image will be read; used if fname=NULL * size: size of the memory buffer from which the image will be read; used if fname=NULL & buf!=NULL * */ //----------------------------------------------------------------------------------- void TFT_jpg_image(int x, int y, uint8_t scale, char *fname, uint8_t *buf, int size); /* * Decodes and displays BMP image * Only uncompressed RGB 24-bit with no color space information BMP images can be displayed * * Params: * x: image left position; constants CENTER & RIGHT can be used; negative value is accepted * y: image top position; constants CENTER & BOTTOM can be used; negative value is accepted * scale: image scale factor: 0~7; if scale>0, image is scaled by factor 1/(scale+1) * fname: pointer to the name of the file from which the image will be read * if set to NULL, image will be read from memory buffer pointed to by 'imgbuf' * imgbuf: pointer to the memory buffer from which the image will be read; used if fname=NULL * size: size of the memory buffer from which the image will be read; used if fname=NULL & imgbuf!=NULL * */ //------------------------------------------------------------------------------------- int TFT_bmp_image(int x, int y, uint8_t scale, char *fname, uint8_t *imgbuf, int size); /* * Decodes and displays PNG image * * Params: * x: image left position; constants CENTER & RIGHT can be used; negative value is accepted * y: image top position; constants CENTER & BOTTOM can be used; negative value is accepted * scale: image scale factor: 0~7; if scale>0, image is scaled by factor 1/(scale+1) * fname: pointer to the name of the file from which the image will be read * if set to NULL, image will be read from memory buffer pointed to by 'imgbuf' * imgbuf: pointer to the memory buffer from which the image will be read; used if fname=NULL * size: size of the memory buffer from which the image will be read; used if fname=NULL & imgbuf!=NULL * */ //------------------------------------------------------------------------------------- int TFT_png_image(int x, int y, uint8_t scale, char *fname, uint8_t *imgbuf, int size); /* * Get the touch panel coordinates. * The coordinates are adjusted to screen orientation if raw=0 * * Params: * x: pointer to X coordinate * y: pointer to Y coordinate * raw: if 0 returns calibrated screen coordinates; if 1 returns raw touch controller coordinates * * Returns: * 0 if touch panel is not touched; x=y=0 * 1 if touch panel is touched; x&y are the valid coordinates */ //---------------------------------------------- int TFT_read_touch(int *x, int* y, uint8_t raw); /* * Compile font c source file to .fnt file * which can be used in TFT_setFont() function to select external font * Created file have the same name as source file and extension .fnt * * Params: * fontfile: pointer to c source font file name; must have .c extension * dbg: if set to 1, prints debug information * * Returns: * 0 on success * err no on error * */ //------------------------------------------------ int compile_font_file(char *fontfile, uint8_t dbg); /* * Get all font's characters to buffer */ void getFontCharacters(uint8_t *buf); extern void TFT_pushBitMap(int x, int y, int w, int h, uint8_t* bitmap, color_t color, color_t bg_color); void led_pwm_init(); void led_setBrightness(int duty); // extern int16_t GetUnicodeWidth(uint32_t code); #endif
YifuLiu/AliOS-Things
components/py_engine/modules/display/esp32/tft/tft.h
C
apache-2.0
27,338
/* * This file is part of the MicroPython ESP32 project, https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo * * The MIT License (MIT) * * Copyright (c) 2018 LoBo (https://github.com/loboris) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ /* * Author: LoBo (loboris@gmail.com, loboris.github) * * Module supporting SPI TFT displays based on ILI9341 & ILI9488 controllers * * HIGH SPEED LOW LEVEL DISPLAY FUNCTIONS * USING DIRECT or DMA SPI TRANSFER MODEs * */ #include "sdkconfig.h" #include <string.h> #include "tftspi.h" #include "esp_system.h" #include "freertos/task.h" #include "esp_heap_caps.h" #include "esp_attr.h" #include "soc/spi_reg.h" #include "esp_log.h" #include "driver/gpio.h" // ==================================================== // ==== Global variables, default values ============== // Converts colors to grayscale if set to 1 uint8_t gray_scale = 0; // Spi clock for reading data from display memory in Hz uint32_t max_rdclock = 4000000; // Default display dimensions int _width = DEFAULT_TFT_DISPLAY_WIDTH; int _height = DEFAULT_TFT_DISPLAY_HEIGHT; // Display type, DISP_TYPE_ILI9488 or DISP_TYPE_ILI9341 uint8_t tft_disp_type = DEFAULT_DISP_TYPE; uint8_t tft_touch_type = TOUCH_TYPE_NONE; // Spi device handles for display and touch screen exspi_device_handle_t *disp_spi = NULL; exspi_device_handle_t *ts_spi = NULL; uint8_t bits_per_color = 16; uint8_t TFT_RGB_BGR = 0; uint8_t gamma_curve = 0; uint32_t spi_speed = 10000000; // ==================================================== color_t *trans_cline = NULL; static const char TAG[] = "[TFTSPI]"; static uint8_t invertrot = 0; uint8_t spibus_is_init = 0; #define PARALLEL_LINES 30 // RGB to GRAYSCALE constants // 0.2989 0.5870 0.1140 #define GS_FACT_R 0.2989 #define GS_FACT_G 0.4870 #define GS_FACT_B 0.2140 // ==== Functions ===================== void IRAM_ATTR tft_spi_post_cb(spi_transaction_t *trans) { if (disp_spi->handle->host) { disp_spi->handle->host->hal.hw->cmd.usr = 0; } } //--------------------- esp_err_t disp_select() { //wait_trans_finish(1); return spi_device_select(disp_spi, 0); } //----------------------- esp_err_t disp_deselect() { //wait_trans_finish(1); return spi_device_deselect(disp_spi); } // Send command with data to display, display must be selected //---------------------------------------------------------------------- void disp_spi_transfer_cmd_data(int8_t cmd, uint8_t *data, uint32_t len) { spi_transfer_cmd_data(disp_spi, cmd, data, len); } // Send 1 byte display command, display must be selected //------------------------------------ void disp_spi_transfer_cmd(int8_t cmd) { spi_transfer_cmd(disp_spi, cmd); } void disp_spi_transfer_data(uint8_t *data, uint32_t len) { spi_transfer_data(disp_spi, data, len); } // Set the address window for display write & read commands, display must be selected //----------------------------------------------------------------------------------------- void disp_spi_transfer_addrwin(uint16_t x1, uint16_t x2, uint16_t y1, uint16_t y2) { uint32_t wd; wd = (uint32_t)(x1 >> 8); wd |= (uint32_t)(x1 & 0xff) << 8; wd |= (uint32_t)(x2 >> 8) << 16; wd |= (uint32_t)(x2 & 0xff) << 24; disp_spi_transfer_cmd_data(TFT_CASET, (uint8_t *)&wd, 4); wd = (uint32_t)(y1 >> 8); wd |= (uint32_t)(y1 & 0xff) << 8; wd |= (uint32_t)(y2 >> 8) << 16; wd |= (uint32_t)(y2 & 0xff) << 24; disp_spi_transfer_cmd_data(TFT_PASET, (uint8_t *)&wd, 4); } // Convert color to gray scale //------------------------------------ static color_t color2gs(color_t color) { color_t _color; float gs_clr = GS_FACT_R * color.r + GS_FACT_G * color.g + GS_FACT_B * color.b; if (gs_clr > 255) gs_clr = 255; _color.r = (uint8_t)gs_clr; _color.g = (uint8_t)gs_clr; _color.b = (uint8_t)gs_clr; return _color; } // Convert color to 16-bit 565 RGB value //------------------------------------ uint16_t color16(color_t color) { uint16_t _color; _color = (uint16_t)(color.r & 0xF8) << 8; _color |= (uint16_t)(color.g & 0xFC) << 3; _color |= (uint16_t)(color.b & 0xF8) >> 3; return _color; } // ============================================ esp_err_t wait_trans_finish(uint8_t free_line) { _wait_trans_finish(disp_spi); if ((free_line) && (trans_cline)) { free(trans_cline); trans_cline = NULL; } return ESP_OK; } // Set display pixel at given coordinates to given color // ============================================================== void drawPixel(int16_t x, int16_t y, color_t color, uint8_t sel) { if ((sel) && (disp_select() != ESP_OK)) return; uint32_t wd = 0; color_t _color = color; if (gray_scale) _color = color2gs(color); wait_trans_finish(1); disp_spi_transfer_addrwin(x, x+1, y, y+1); // Send RAM WRITE command disp_spi_transfer_cmd(TFT_RAMWR); if (bits_per_color == 16) { uint16_t _color16 = color16(_color); wd = (uint32_t)(_color16 >> 8); wd |= (uint32_t)(_color16 & 0xFF) << 8; } else { wd = (uint32_t)_color.r; wd |= (uint32_t)_color.g << 8; wd |= (uint32_t)_color.b << 16; } disp_spi_transfer_cmd_data(TFT_RAMWR, (uint8_t *)&wd, bits_per_color / 8); if (sel) disp_deselect(); } // Send colors from color buffer directly, maximum of 512 bits //----------------------------------------------------------------- static void _direct_send(color_t *color, uint32_t len, uint8_t rep) { uint32_t cidx = 0; // color buffer index uint32_t wd = 0; uint16_t _color16 = 0; int idx = 0; int bits = 0; int wbits = 0; uint32_t buf[32]; // Get first color data from color buffer (repeat color) color_t _color = color[0]; if ((rep) && (gray_scale)) _color = color2gs(color[0]); if (bits_per_color == 16) _color16 = color16(_color); while (len) { if (rep == 0) { // Get color data from color buffer if (gray_scale) _color = color2gs(color[cidx]); else _color = color[cidx]; if (bits_per_color == 16) _color16 = color16(_color); } if (bits_per_color == 16) { wd |= (uint32_t)(_color16 >> 8) << wbits; wbits += 8; wd |= (uint32_t)(_color16 & 0xFF) << wbits; wbits += 8; if (wbits == 32) { bits += wbits; wbits = 0; buf[idx++] = wd; wd = 0; } } else { wd |= (uint32_t)_color.r << wbits; wbits += 8; if (wbits == 32) { bits += wbits; wbits = 0; buf[idx++] = wd; wd = 0; } wd |= (uint32_t)_color.g << wbits; wbits += 8; if (wbits == 32) { bits += wbits; wbits = 0; buf[idx++] = wd; wd = 0; } wd |= (uint32_t)_color.b << wbits; wbits += 8; if (wbits == 32) { bits += wbits; wbits = 0; buf[idx++] = wd; wd = 0; } } len--; // Decrement colors counter cidx++; // increment color buffer index (used only if not repeating color) } if (bits) spi_transfer_data(disp_spi, (uint8_t *)buf, bits / 8); } // ================================================================== // === Main function to send data to display ======================== // If rep==true: repeat sending color data to display 'len' times // If rep==false: send 'len' color data from color buffer to display // ** Device must already be selected and address window set ** // ================================================================== //------------------------------------------------------------------------------------ static void _TFT_pushColorRep(color_t *color, uint32_t len, uint8_t rep, uint8_t wait) { if (len == 0) return; // Send RAM WRITE command disp_spi_transfer_cmd(TFT_RAMWR); if ((len * bits_per_color) <= 512) { // --- up to 512 bits, send directly --- _direct_send(color, len, rep); } else if (rep == 0) { // --- more than 512 bits, no repeat: use DMA transfer --- if (trans_cline) return; int buflen = ((len * bits_per_color) + 31) / 8; trans_cline = heap_caps_malloc(buflen, MALLOC_CAP_DMA); if (trans_cline == NULL) return; // ** Prepare data if ((!gray_scale) && (bits_per_color != 16)) { memcpy(trans_cline, color, len*(bits_per_color/8)); } else { color_t _color; uint16_t _color16; uint8_t *trans_cline16 = (uint8_t *)trans_cline; for (int n=0; n<len; n++) { if (gray_scale) _color = color2gs(color[n]); else _color = color[n]; if (bits_per_color == 16) { _color16 = color16(_color); trans_cline16[n*2] = (uint8_t)(_color16 >> 8); trans_cline16[(n*2)+1] = (uint8_t)(_color16 & 0xFF); } else trans_cline[n] = _color; } } _dma_send(disp_spi, (uint8_t *)trans_cline, len * (bits_per_color/8)); } else { // --- more than 512 bits, repeat color --- if (trans_cline) return; color_t _color; uint16_t _color16 = 0; uint8_t *trans_cline16 = NULL; uint32_t buf_colors; int buf_bytes, to_send; // Prepare color buffer of maximum 2 lines buf_colors = ((len > (_width*2)) ? (_width*2) : len); buf_bytes = buf_colors * (bits_per_color / 8); int buflen = ((buf_bytes*8) + 31) / 8; trans_cline = heap_caps_malloc(buflen, MALLOC_CAP_DMA); if (trans_cline == NULL) return; // Prepare fill color if (gray_scale) _color = color2gs(color[0]); else _color = color[0]; if (bits_per_color == 16) { _color16 = color16(_color); trans_cline16 = (uint8_t *)trans_cline; } // Fill color buffer with fill color for (uint32_t i=0; i<buf_colors; i++) { if (bits_per_color == 16) { trans_cline16[i*2] = (uint8_t)(_color16 >> 8); trans_cline16[(i*2)+1] = (uint8_t)(_color16 & 0xFF); } else trans_cline[i] = _color; } // Send 'len' colors to_send = len; while (to_send > 0) { wait_trans_finish(0); _dma_send(disp_spi, (uint8_t *)trans_cline, ((to_send > buf_colors) ? buf_bytes : (to_send * (bits_per_color/8)))); to_send -= buf_colors; } } if (wait) wait_trans_finish(1); } // Write 'len' color data to TFT 'window' (x1,y2),(x2,y2) // ================================================================================ void TFT_pushColorRep(int x1, int y1, int x2, int y2, color_t color, uint32_t len) { if (disp_select() != ESP_OK) return; wait_trans_finish(1); // ** Send address window ** disp_spi_transfer_addrwin(x1, x2, y1, y2); // Send repeated color and wait for all data sent _TFT_pushColorRep(&color, len, 1, 1); disp_deselect(); } // Write 'len' color data to TFT 'window' (x1,y2),(x2,y2) from given buffer // === Device must already be selected === // ====================================================================================== extern void ili9341_send_cmd(uint8_t cmd); extern void ili9341_send_data(void *data, uint16_t length); extern void ili9341_send_color(void *data, uint16_t length); void send_data(int x1, int y1, int x2, int y2, uint32_t len, color_t *buf, uint8_t wait) { #if 0 uint8_t data[4]; /*Column addresses*/ ili9341_send_cmd(TFT_CASET); data[0] = (x1 >> 8) & 0xFF; data[1] = x1 & 0xFF; data[2] = (x2 >> 8) & 0xFF; data[3] = x2 & 0xFF; ili9341_send_data(data, 4); /*Page addresses*/ ili9341_send_cmd(TFT_PASET); data[0] = (y1 >> 8) & 0xFF; data[1] = y1 & 0xFF; data[2] = (y2 >> 8) & 0xFF; data[3] = y2 & 0xFF; ili9341_send_data(data, 4); /*Memory write*/ ili9341_send_cmd(TFT_RAMWR); uint32_t size = (x2 - x1) * (y2 - y1); ili9341_send_color((void *)buf, size * 2); #else wait_trans_finish(1); // ** Send address window ** disp_spi_transfer_addrwin(x1, x2, y1, y2); // Send color buffer _TFT_pushColorRep(buf, len, 0, wait); #endif } // ========================================= uint32_t read_cmd(uint8_t cmd, uint8_t len) { if (disp_select() != ESP_OK) return -2; // // Send command command // disp_spi_transfer_cmd(cmd); // while (disp_spi->handle->host->hw->cmd.usr); // Wait for SPI bus ready // // Read data; // gpio_set_level(disp_spi->dc, 1); // disp_spi->handle->host->hw->data_buf[0] = 0xFFFFFFFF; // _spi_transfer_start(disp_spi, 0, len*8); // while (disp_spi->handle->host->hw->cmd.usr); // Wait for SPI bus ready // uint32_t res = disp_spi->handle->host->hw->data_buf[0]; disp_deselect(); return ESP_ERR_NOT_SUPPORTED;; } // Reads 'len' pixels/colors from the TFT's GRAM 'window' // 'buf' is an array of bytes with 1st byte reserved for reading 1 dummy byte // and the rest is actually an array of color_t values // ================================================================================== int read_data(int x1, int y1, int x2, int y2, int len, uint8_t *buf, uint8_t set_sp) { // spi_transaction_t t; // uint32_t current_clock = 0; // memset(&t, 0, sizeof(t)); //Zero out the transaction // memset(buf, 0, len*sizeof(color_t)); // if (set_sp) { // if (disp_deselect() != ESP_OK) return -1; // // Change spi clock if needed // current_clock = spi_get_speed(disp_spi); // if (max_rdclock < current_clock) spi_set_speed(disp_spi, max_rdclock); // } // if (disp_select() != ESP_OK) return -2; // // ** Send address window ** // disp_spi_transfer_addrwin(x1, x2, y1, y2); // // ** GET pixels/colors ** // disp_spi_transfer_cmd(TFT_RAMRD); // t.length = 0; //Send nothing // t.tx_buffer = NULL; // t.rxlength = 8 * ((len*3)+1); //Receive size in bits // t.rx_buffer = buf; // esp_err_t res = spi_transfer_data_nodma(disp_spi, &t); // Receive using direct mode // disp_deselect(); // if (set_sp) { // // Restore spi clock if needed // if (max_rdclock < current_clock) spi_set_speed(disp_spi, current_clock); // } return ESP_ERR_NOT_SUPPORTED; } // Reads one pixel/color from the TFT's GRAM at position (x,y) // ===================================== color_t readPixel(int16_t x, int16_t y) { uint8_t color_buf[sizeof(color_t)+1] = {0}; read_data(x, y, x+1, y+1, 1, color_buf, 1); color_t color; color.r = color_buf[1]; color.g = color_buf[2]; color.b = color_buf[3]; return color; } // get 16-bit data from touch controller for specified type // ** Touch device must already be selected ** // ============================== int touch_get_data(uint8_t type) { /* while (ts_spi->handle->host->hw->cmd.usr); // Wait for SPI bus ready ts_spi->handle->host->hw->data_buf[0] = type; _spi_transfer_start(ts_spi, 24, 24); uint16_t res = (uint16_t)(ts_spi->handle->host->hw->data_buf[0] >> 8); while (ts_spi->handle->host->hw->cmd.usr); // Wait for SPI bus ready */ spi_transaction_t t; memset(&t, 0, sizeof(t)); //Zero out the transaction uint32_t buf = type; t.length = 24; t.tx_buffer = (uint8_t *)&buf; t.rxlength = 24; t.rx_buffer = (uint8_t *)&buf; esp_err_t ret = spi_transfer_data_nodma(ts_spi, &t); if (ret != ESP_OK) return 0; uint16_t res = (uint16_t)(buf >> 8); return res; } //--------------------------------------------------------------------------- // Companion code to the initialization table. // Reads and issues a series of LCD commands stored in byte array //-------------------------------------------- static void commandList(const uint8_t *addr) { uint8_t numCommands, numArgs, cmd; uint16_t ms; numCommands = *addr++; // Number of commands to follow while(numCommands--) { // For each command... cmd = *addr++; // save command numArgs = *addr++; // Number of args to follow ms = numArgs & TFT_CMD_DELAY; // If high bit set, delay follows args numArgs &= ~TFT_CMD_DELAY; // Mask out delay bit disp_spi_transfer_cmd_data(cmd, (uint8_t *)addr, numArgs); addr += numArgs; if(ms) { ms = *addr++; // Read post-command delay time (ms) if(ms == 255) ms = 500; // If 255, delay for 500 ms vTaskDelay(ms / portTICK_RATE_MS); } } } // ================================== void _tft_setRotation(uint8_t rot) { uint8_t rotation = rot & 3; // can't be higher than 3 uint8_t send = 1; uint8_t madctl = 0; uint16_t tmp; if ((rotation & 1)) { // in landscape modes must be width > height if (_width < _height) { tmp = _width; _width = _height; _height = tmp; } } else { // in portrait modes must be width < height if (_width > _height) { tmp = _width; _width = _height; _height = tmp; } } if (invertrot == 2) { switch (rotation) { case PORTRAIT: madctl = (MADCTL_MV | TFT_RGB_BGR); break; case LANDSCAPE: madctl = (MADCTL_MX | TFT_RGB_BGR); break; case PORTRAIT_FLIP: madctl = (MADCTL_MV | TFT_RGB_BGR); break; case LANDSCAPE_FLIP: madctl = (MADCTL_MY | TFT_RGB_BGR); break; } } else if (invertrot == 3) { // used for M5Stack display switch (rotation) { case PORTRAIT: madctl = (MADCTL_MX | MADCTL_MV | TFT_RGB_BGR); break; case LANDSCAPE: madctl = (TFT_RGB_BGR); break; case PORTRAIT_FLIP: madctl = (MADCTL_MY | MADCTL_MV | TFT_RGB_BGR); break; case LANDSCAPE_FLIP: madctl = (MADCTL_MY | MADCTL_MX | TFT_RGB_BGR); break; } } else if (invertrot == 1) { switch (rotation) { case PORTRAIT: madctl = (MADCTL_MY | MADCTL_MX | TFT_RGB_BGR); break; case LANDSCAPE: madctl = (MADCTL_MY | MADCTL_MV | TFT_RGB_BGR); break; case PORTRAIT_FLIP: madctl = (TFT_RGB_BGR); break; case LANDSCAPE_FLIP: madctl = (MADCTL_MX | MADCTL_MV | TFT_RGB_BGR); break; } } else { switch (rotation) { case PORTRAIT: madctl = (MADCTL_MX | TFT_RGB_BGR); break; case LANDSCAPE: madctl = (MADCTL_MV | TFT_RGB_BGR); break; case PORTRAIT_FLIP: madctl = (MADCTL_MY | TFT_RGB_BGR); break; case LANDSCAPE_FLIP: madctl = (MADCTL_MX | MADCTL_MY | MADCTL_MV | TFT_RGB_BGR); break; } } if (send) { if (disp_select() == ESP_OK) { disp_spi_transfer_cmd_data(TFT_MADCTL, &madctl, 1); disp_deselect(); } } } //--------------------------------------- void bcklOff(display_config_t *dconfig) { if (dconfig->bckl >= 0) { gpio_set_level(dconfig->bckl, (dconfig->bckl_on & 1) ^ 1); } } //-------------------------------------- void bcklOn(display_config_t *dconfig) { if (dconfig->bckl >= 0) { gpio_set_level(dconfig->bckl, dconfig->bckl_on & 1); } } // =========================================== void _tft_setBitsPerColor(uint8_t bitsperc) { if ((tft_disp_type != DISP_TYPE_ILI9488) && ((bitsperc == 16) || (bitsperc == 24))) { uint8_t bpc = DISP_COLOR_BITS_16; if (bitsperc == 24) bpc = DISP_COLOR_BITS_24; if (disp_select() == ESP_OK) { disp_spi_transfer_cmd_data(TFT_CMD_PIXFMT, &bpc, 1); disp_deselect(); } bits_per_color = bitsperc; } } //-------------------------------------------------------- static void TFT_PinsInit(display_config_t *dconfig) { // Route all used pins to GPIO control if (!spibus_is_init) { gpio_pad_select_gpio(dconfig->miso); gpio_pad_select_gpio(dconfig->mosi); gpio_pad_select_gpio(dconfig->sck); gpio_set_direction(dconfig->miso, GPIO_MODE_INPUT); gpio_set_pull_mode(dconfig->miso, GPIO_PULLUP_ONLY); gpio_set_direction(dconfig->mosi, GPIO_MODE_OUTPUT); gpio_set_direction(dconfig->sck, GPIO_MODE_OUTPUT); } gpio_pad_select_gpio(dconfig->cs); gpio_pad_select_gpio(dconfig->dc); gpio_set_direction(dconfig->cs, GPIO_MODE_OUTPUT); gpio_set_direction(dconfig->dc, GPIO_MODE_OUTPUT); gpio_set_level(dconfig->dc, 0); gpio_set_level(dconfig->cs, 1); if (dconfig->bckl >= 0) { gpio_pad_select_gpio(dconfig->bckl); gpio_set_direction(dconfig->bckl, GPIO_MODE_OUTPUT); gpio_set_level(dconfig->bckl, dconfig->bckl_on ^ 1); } if (dconfig->rst >= 0) { gpio_pad_select_gpio(dconfig->rst); gpio_set_direction(dconfig->rst, GPIO_MODE_OUTPUT); gpio_set_level(dconfig->rst, 0); } disp_spi->dc = dconfig->dc; gpio_pad_select_gpio(13); gpio_set_direction(13, GPIO_MODE_OUTPUT); } //----------------------------------------------------- static esp_err_t TFT_spiInit(display_config_t *dconfig) { esp_err_t ret; disp_spi->spihost = dconfig->host; disp_spi->buscfg = SPIbus_configs[disp_spi->spihost]; if (disp_spi->buscfg == NULL) { ESP_LOGE(TAG, "spi bus %d not available ", disp_spi->spihost); return ESP_ERR_INVALID_ARG; } disp_spi->buscfg->miso_io_num = dconfig->miso; // set SPI MISO pin disp_spi->buscfg->mosi_io_num = dconfig->mosi; // set SPI MOSI pin disp_spi->buscfg->sclk_io_num = dconfig->sck; // set SPI CLK pin disp_spi->buscfg->quadwp_io_num = -1; disp_spi->buscfg->quadhd_io_num = -1; disp_spi->buscfg->max_transfer_sz = PARALLEL_LINES * dconfig->width * 2 + 8; memset(&disp_spi->devcfg, 0, sizeof(spi_device_interface_config_t)); disp_spi->devcfg.clock_speed_hz = dconfig->speed; // Initial clock disp_spi->devcfg.mode = 0; // SPI mode 0 disp_spi->devcfg.spics_io_num = dconfig->cs; // we will use hardware cs select disp_spi->devcfg.queue_size = 2; // we need only one transaction disp_spi->devcfg.flags = SPI_DEVICE_NO_DUMMY; // ALWAYS SET to HALF DUPLEX MODE!! for display spi disp_spi->dma_channel = 1; disp_spi->cs = dconfig->cs; ret = spi_device_init(disp_spi); if (ret != ESP_OK) printf("spi_device_init fail, ret: %d\n", ret); ESP_LOGD(TAG, "spi bus configured (%d)", disp_spi->spihost); // ==== Test select/deselect ==== ret = spi_device_select(disp_spi, 1); if (ret != ESP_OK) { ESP_LOGE(TAG, "Error selecting display device"); } vTaskDelay(10 / portTICK_RATE_MS); ret = spi_device_deselect(disp_spi); if (ret != ESP_OK) { ESP_LOGE(TAG, "Error deselecting display device"); } return ESP_OK; } // ================================================= void TFT_display_setvars(display_config_t *dconfig) { // === SET GLOBAL VARIABLES ========================== tft_disp_type = dconfig->type; tft_touch_type = dconfig->touch; _width = dconfig->width; _height = dconfig->height; // ==== Set maximum spi clock for display read ==== // operations, function 'find_rd_speed()' ==== // can be used after display initialization ==== max_rdclock = dconfig->rdspeed; TFT_RGB_BGR = dconfig->bgr; gamma_curve = dconfig->gamma; spi_speed = dconfig->speed; bits_per_color = dconfig->color_bits; invertrot = dconfig->invrot; // =================================================== } // Initialize the display // ================================================== esp_err_t TFT_display_init(display_config_t *dconfig) { esp_err_t ret; uint8_t tft_version = 0; tft_version = 1; TFT_PinsInit(dconfig); ret = TFT_spiInit(dconfig); if (ret != ESP_OK) return ret; TFT_display_setvars(dconfig); if (dconfig->rst >= 0) { //Reset the display gpio_set_level(dconfig->rst, 0); vTaskDelay(1 / portTICK_RATE_MS); gpio_set_level(dconfig->rst, 1); vTaskDelay(60 / portTICK_RATE_MS); } else { disp_spi_transfer_cmd_data(TFT_CMD_SWRESET, NULL, 0); vTaskDelay(200 / portTICK_RATE_MS); } disp_select(); // uint8_t data[4] = {0x00, 0x01, 0x02, 0x55}; // for (;;) { // disp_spi_transfer_cmd_data(0xaa, data, 4); // } //Send all the initialization commands if ((tft_disp_type == DISP_TYPE_ILI9341) || (tft_disp_type == DISP_TYPE_M5STACK)) { if (dconfig->rst < 0) { vTaskDelay(50 / portTICK_RATE_MS); } if(tft_version) { commandList(ILI9342_init); disp_spi_transfer_cmd(0x21); dconfig->invrot = 1; } else { commandList(ILI9341_init); dconfig->invrot = 1; } } else if (tft_disp_type == DISP_TYPE_ILI9488) { commandList(ILI9488_init); } else if (tft_disp_type == DISP_TYPE_ST7789V) { commandList(ST7789V_init); _tft_setBitsPerColor(bits_per_color); } else if (tft_disp_type == DISP_TYPE_ST7735) { commandList(STP7735_init); } else if (tft_disp_type == DISP_TYPE_ST7735R) { commandList(STP7735R_init); commandList(Rcmd2green); commandList(Rcmd3); } else if (tft_disp_type == DISP_TYPE_ST7735B) { commandList(STP7735R_init); commandList(Rcmd2red); commandList(Rcmd3); uint8_t dt = 0xC0; disp_spi_transfer_cmd_data(TFT_MADCTL, &dt, 1); } else if (tft_disp_type == DISP_TYPE_GENERIC) { ESP_LOGW(TAG, "Generic display type, you must init the display manually"); ///Enable backlight if (dconfig->bckl >= 0) { gpio_set_level(dconfig->bckl, dconfig->bckl_on); } return ESP_OK; } else { ESP_LOGE(TAG, "Display type %d not supported", tft_disp_type); disp_deselect(); return ESP_FAIL; } disp_deselect(); if(tft_version) { _tft_setBitsPerColor(bits_per_color); _tft_setRotation(LANDSCAPE_FLIP); } else { _tft_setRotation(LANDSCAPE); } // Clear screen ///Enable backlight if (dconfig->bckl >= 0) { gpio_set_level(dconfig->bckl, dconfig->bckl_on); } return ESP_OK; } // ==== STMPE610 =============================================================== // ----- STMPE610 -------------------------------------------------------------------------- //------------------------------------------------------ static void stmpe610_write_reg(uint8_t reg, uint8_t val) { } //-------------------------------------------- static uint8_t stmpe610_read_byte(uint8_t reg) { return 0; } //--------------------------------------------- static uint16_t stmpe610_read_word(uint8_t reg) { return 0; } //----------------------- uint32_t stmpe610_getID() { return 0; } // ================== void stmpe610_Init() { } //--------------------------------------------------------------- static void stmpe_readData(uint32_t *x, uint32_t *y, uint32_t *z) { } // =========================================================== int stmpe610_get_touch(uint16_t *x, uint16_t *y, uint16_t *z) { return 1; } // ==== STMPE610 ===========================================================================
YifuLiu/AliOS-Things
components/py_engine/modules/display/esp32/tft/tftspi.c
C
apache-2.0
29,470
/* * This file is part of the MicroPython ESP32 project, https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo * * The MIT License (MIT) * * Copyright (c) 2018 LoBo (https://github.com/loboris) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ /* * * HIGH SPEED LOW LEVEL DISPLAY FUNCTIONS USING DIRECT TRANSFER MODE * */ #ifndef _TFTSPI_H_ #define _TFTSPI_H_ #include "sdkconfig.h" #include "tftspi_hal.h" #include "stmpe610.h" typedef struct { uint32_t speed; // SPI clock in Hz uint32_t rdspeed; // Read SPI clock in Hz uint8_t type; // Display type, use one of the defined DISP_TYPE_* values uint8_t host; // SPI host (HSPI_HOST or VSPI_HOST) uint8_t miso; // SPI MISO pin uint8_t mosi; // SPI MOSI pin uint8_t sck; // SPI CLOCK pin uint8_t cs; // Display CS pin uint8_t dc; // Display DC pin (command/data) int8_t tcs; // Touch screen CS pin int8_t rst; // GPIO used for RESET control int8_t bckl; // GPIO used for backlight control uint8_t bckl_on; // GPIO value for backlight ON uint8_t color_bits; // Bits per color (16 or 24) uint8_t gamma; // Gamma curve used uint16_t width; // Display width (smaller dimension) uint16_t height; // Display height (larger dimension) uint8_t invrot; // rotation uint8_t bgr; // SET TO 0X00 FOR DISPLAYS WITH RGB MATRIX, 0x08 FOR DISPLAYS WITH BGR MATRIX uint8_t touch; // Touch panel type } display_config_t; // 24-bit color type structure typedef struct __attribute__((__packed__)) { uint8_t r; uint8_t g; uint8_t b; } color_t ; #define DISP_COLOR_BITS_24 0x66 #define DISP_COLOR_BITS_16 0x55 #define DISP_COLOR_BITS DISP_COLOR_BITS_16 #define TOUCH_TYPE_NONE 0 #define TOUCH_TYPE_XPT2046 1 #define TOUCH_TYPE_STMPE610 2 #define TP_CALX_XPT2046 7472920 #define TP_CALY_XPT2046 122224794 #define TP_CALX_STMPE610 21368532 #define TP_CALY_STMPE610 11800144 // === Screen orientation constants === #define PORTRAIT 0 #define LANDSCAPE 1 #define PORTRAIT_FLIP 2 #define LANDSCAPE_FLIP 3 #define DISP_TYPE_ILI9341 0 #define DISP_TYPE_ILI9488 1 #define DISP_TYPE_ST7789V 2 #define DISP_TYPE_ST7735 3 #define DISP_TYPE_ST7735R 4 #define DISP_TYPE_ST7735B 5 #define DISP_TYPE_M5STACK 6 #define DISP_TYPE_GENERIC 7 #define DISP_TYPE_MAX 8 #define DEFAULT_TFT_DISPLAY_WIDTH 320 #define DEFAULT_TFT_DISPLAY_HEIGHT 240 #define DEFAULT_DISP_TYPE DISP_TYPE_ILI9341 /* #define WROVER_V3_CONFIG() {\ .type = DISP_TYPE_ST7789V, \ .host = HSPI_HOST, \ .speed = 26000000, \ .miso = 25, \ .mosi = 23, \ .sck = 19, \ .cs = 22, \ .dc = 21, \ .tcs = -1, \ .rst = 18, \ .bckl = 5, \ .bckl_on = 0, \ .color_bits = 24, \ .gamma = 0, \ .width = 240, \ .height = 320, \ .invrot = 1, \ .bgr = 0, \ .touch = TOUCH_TYPE_NONE \ } */ // ############################################################## // #### Global variables #### // ############################################################## // ==== Converts colors to grayscale if 1 ======================= extern uint8_t gray_scale; // ==== Spi clock for reading data from display memory in Hz ==== extern uint32_t max_rdclock; // ==== Display dimensions in pixels ============================ extern int _width; extern int _height; // ==== Display & touch type ==== extern uint8_t tft_disp_type; extern uint8_t tft_touch_type; // ==== Spi device handles for display and touch screen ========= extern exspi_device_handle_t *disp_spi; extern exspi_device_handle_t *ts_spi; extern uint8_t bits_per_color; extern uint8_t TFT_RGB_BGR; extern uint8_t gamma_curve; extern uint32_t spi_speed; extern uint8_t spibus_is_init; // ############################################################## // ==== Display commands constants ==== #define TFT_INVOFF 0x20 #define TFT_INVONN 0x21 #define TFT_DISPOFF 0x28 #define TFT_DISPON 0x29 #define TFT_MADCTL 0x36 #define TFT_PTLAR 0x30 #define TFT_ENTRYM 0xB7 #define TFT_CMD_NOP 0x00 #define TFT_CMD_SWRESET 0x01 #define TFT_CMD_RDDID 0x04 #define TFT_CMD_RDDST 0x09 #define TFT_CMD_SLPIN 0x10 #define TFT_CMD_SLPOUT 0x11 #define TFT_CMD_PTLON 0x12 #define TFT_CMD_NORON 0x13 #define TFT_CMD_RDMODE 0x0A #define TFT_CMD_RDMADCTL 0x0B #define TFT_CMD_RDPIXFMT 0x0C #define TFT_CMD_RDIMGFMT 0x0D #define TFT_CMD_RDSELFDIAG 0x0F #define TFT_CMD_GAMMASET 0x26 #define TFT_CMD_FRMCTR1 0xB1 #define TFT_CMD_FRMCTR2 0xB2 #define TFT_CMD_FRMCTR3 0xB3 #define TFT_CMD_INVCTR 0xB4 #define TFT_CMD_DFUNCTR 0xB6 #define TFT_CMD_PWCTR1 0xC0 #define TFT_CMD_PWCTR2 0xC1 #define TFT_CMD_PWCTR3 0xC2 #define TFT_CMD_PWCTR4 0xC3 #define TFT_CMD_PWCTR5 0xC4 #define TFT_CMD_VMCTR1 0xC5 #define TFT_CMD_VMCTR2 0xC7 #define TFT_CMD_RDID1 0xDA #define TFT_CMD_RDID2 0xDB #define TFT_CMD_RDID3 0xDC #define TFT_CMD_RDID4 0xDD #define TFT_CMD_GMCTRP1 0xE0 #define TFT_CMD_GMCTRN1 0xE1 #define TFT_CMD_POWERA 0xCB #define TFT_CMD_POWERB 0xCF #define TFT_CMD_POWER_SEQ 0xED #define TFT_CMD_DTCA 0xE8 #define TFT_CMD_DTCB 0xEA #define TFT_CMD_PRC 0xF7 #define TFT_CMD_3GAMMA_EN 0xF2 #define ST_CMD_VCOMS 0xBB #define ST_CMD_FRCTRL2 0xC6 #define ST_CMD_PWCTR1 0xD0 #define ST7735_FRMCTR1 0xB1 #define ST7735_FRMCTR2 0xB2 #define ST7735_FRMCTR3 0xB3 #define ST7735_INVCTR 0xB4 #define ST7735_DISSET5 0xB6 #define ST7735_PWCTR1 0xC0 #define ST7735_PWCTR2 0xC1 #define ST7735_PWCTR3 0xC2 #define ST7735_PWCTR4 0xC3 #define ST7735_PWCTR5 0xC4 #define ST7735_VMCTR1 0xC5 #define ST7735_RDID1 0xDA #define ST7735_RDID2 0xDB #define ST7735_RDID3 0xDC #define ST7735_RDID4 0xDD #define ST7735_NOP 0x00 #define ST7735_SWRESET 0x01 #define ST7735_RDDID 0x04 #define ST7735_RDDST 0x09 #define ST7735_SLPIN 0x10 #define ST7735_SLPOUT 0x11 #define ST7735_PTLON 0x12 #define ST7735_NORON 0x13 #define ST7735_PWCTR6 0xFC #define ST7735_GMCTRP1 0xE0 #define ST7735_GMCTRN1 0xE1 #define MADCTL_MY 0x80 #define MADCTL_MX 0x40 #define MADCTL_MV 0x20 #define MADCTL_ML 0x10 #define MADCTL_MH 0x04 #define TFT_CASET 0x2A #define TFT_PASET 0x2B #define TFT_RAMWR 0x2C #define TFT_RAMRD 0x2E #define TFT_CMD_PIXFMT 0x3A #define TFT_CMD_DELAY 0x80 // Initialization sequence for ILI7749 // ==================================== static const uint8_t ST7789V_init[] = { 15, // 15 commands in list TFT_CMD_FRMCTR2, 5, 0x0c, 0x0c, 0x00, 0x33, 0x33, TFT_ENTRYM, 1, 0x45, ST_CMD_VCOMS, 1, 0x2B, TFT_CMD_PWCTR1, 1, 0x2C, TFT_CMD_PWCTR3, 2, 0x01, 0xff, TFT_CMD_PWCTR4, 1, 0x11, TFT_CMD_PWCTR5, 1, 0x20, ST_CMD_FRCTRL2, 1, 0x0f, ST_CMD_PWCTR1, 2, 0xA4, 0xA1, TFT_CMD_GMCTRP1, 14, 0xD0, 0x00, 0x05, 0x0E, 0x15, 0x0D, 0x37, 0x43, 0x47, 0x09, 0x15, 0x12, 0x16, 0x19, TFT_CMD_GMCTRN1, 14, 0xD0, 0x00, 0x05, 0x0D, 0x0C, 0x06, 0x2D, 0x44, 0x40, 0x0E, 0x1C, 0x18, 0x16, 0x19, TFT_MADCTL, 1, (MADCTL_MX | 8), // Memory Access Control (orientation) TFT_CMD_PIXFMT, 1, DISP_COLOR_BITS_16, // *** INTERFACE PIXEL FORMAT: 0x66 -> 18 bit; 0x55 -> 16 bit TFT_CMD_SLPOUT, TFT_CMD_DELAY, 120, // Sleep out, // 120 ms delay TFT_DISPON, TFT_CMD_DELAY, 120, }; // Initialization sequence for ILI7341 // ==================================== static const uint8_t ILI9341_init[] = { 23, // 22 commands in list TFT_CMD_POWERA, 5, 0x39, 0x2C, 0x00, 0x34, 0x02, TFT_CMD_POWERB, 3, 0x00, 0XC1, 0X30, 0xEF, 3, 0x03, 0x80, 0x02, TFT_CMD_DTCA, 3, 0x85, 0x00, 0x78, TFT_CMD_DTCB, 2, 0x00, 0x00, TFT_CMD_POWER_SEQ, 4, 0x64, 0x03, 0X12, 0X81, TFT_CMD_PRC, 1, 0x20, TFT_CMD_PWCTR1, 1, 0x23, //Power control VRH[5:0] TFT_CMD_PWCTR2, 1, 0x10, //Power control SAP[2:0];BT[3:0] TFT_CMD_VMCTR1, 2, 0x3e, 0x28, //VCM control TFT_CMD_VMCTR2, 1, 0x86, //VCM control2 TFT_MADCTL, 1, (MADCTL_MX | 8), // Memory Access Control (orientation) // *** INTERFACE PIXEL FORMAT: 0x66 -> 18 bit; 0x55 -> 16 bit TFT_CMD_PIXFMT, 1, DISP_COLOR_BITS_16, TFT_INVOFF, 0, TFT_CMD_FRMCTR1, 2, 0x00, 0x18, TFT_CMD_DFUNCTR, 4, 0x08, 0x82, 0x27, 0x00, // Display Function Control TFT_PTLAR, 4, 0x00, 0x00, 0x01, 0x3F, TFT_CMD_3GAMMA_EN, 1, 0x00, // 3Gamma Function: Disable (0x02), Enable (0x03) TFT_CMD_GAMMASET, 1, 0x01, //Gamma curve selected (0x01, 0x02, 0x04, 0x08) TFT_CMD_GMCTRP1, 15, //Positive Gamma Correction 0x0F, 0x31, 0x2B, 0x0C, 0x0E, 0x08, 0x4E, 0xF1, 0x37, 0x07, 0x10, 0x03, 0x0E, 0x09, 0x00, TFT_CMD_GMCTRN1, 15, //Negative Gamma Correction 0x00, 0x0E, 0x14, 0x03, 0x11, 0x07, 0x31, 0xC1, 0x48, 0x08, 0x0F, 0x0C, 0x31, 0x36, 0x0F, TFT_CMD_SLPOUT, TFT_CMD_DELAY, // Sleep out 6, // 120 ms delay TFT_DISPON, TFT_CMD_DELAY, 1, }; static const uint8_t ILI9342_init[] = { 16, // 22 commands in list 0xC8, 3, 0xFF, 0x93, 0x42, 0xC5, 1, 0xf0, //F5 E8 ///1 0xC0, 2, 0x12, 0x12, 0xC1, 1, 0x03, 0x2A, 4, 0x00, 0x00, 0x01, 0x3f, 0x2B, 4, 0x00, 0x00, 0x00, 0xef, 0xb0, 1, 0xe0, 0xf6, 3, 0x00, 0x01, 0x01, 0xb6, 4, 0x0a, 0xe0, 0x1d, 0x04, 0xC2, 1, 0xA3, 0xB4, 1, 0x02, 0xE0,15,0x00,0x0C,0x11,0x04,0x11,0x08,0x37,0x89,0x4C,0x06,0x0C,0x0A,0x2E,0x34,0x0F, 0xE1,15,0x00,0x0B,0x11,0x05,0x13,0x09,0x33,0x67,0x48,0x07,0x0E,0x0B,0x2E,0x33,0x0F, ///0xB6, 2, 0x0A, 0x40, ///2 0x11, TFT_CMD_DELAY, 6, 0x29, TFT_CMD_DELAY, 1, 0x36, 1, 0x08, }; // Initialization sequence for ILI9488 // ==================================== static const uint8_t ILI9488_init[] = { 17, // 17 commands in list 0xE0, 15, 0x00, 0x03, 0x09, 0x08, 0x16, 0x0A, 0x3F, 0x78, 0x4C, 0x09, 0x0A, 0x08, 0x16, 0x1A, 0x0F, 0xE1, 15, 0x00, 0x16, 0x19, 0x03, 0x0F, 0x05, 0x32, 0x45, 0x46, 0x04, 0x0E, 0x0D, 0x35, 0x37, 0x0F, 0xC0, 2, //Power Control 1 0x17, //Vreg1out 0x15, //Verg2out 0xC1, 1, //Power Control 2 0x41, //VGH,VGL 0xC5, 3, //Power Control 3 0x00, 0x12, //Vcom 0x80, TFT_MADCTL, 1, MADCTL_MX, // Memory Access Control (orientation), set to portrait // *** INTERFACE PIXEL FORMAT: 0x66 -> 18 bit; TFT_CMD_PIXFMT, 1, DISP_COLOR_BITS_24, 0xB0, 1, // Interface Mode Control 0x00, // 0x80: SDO NOT USE; 0x00 USE SDO 0xB1, 1, //Frame rate 0xA0, //60Hz 0xB4, 1, //Display Inversion Control 0x02, //2-dot 0xB6, 2, //Display Function Control RGB/MCU Interface Control 0x02, //MCU 0x02, //Source,Gate scan direction 0xE9, 1, // Set Image Function 0x00, // Disable 24 bit data 0x53, 1, // Write CTRL Display Value 0x28, // BCTRL && DD on 0x51, 1, // Write Display Brightness Value 0x7F, // 0xF7, 4, // Adjust Control 0xA9, 0x51, 0x2C, 0x02, // D7 stream, loose 0x11, TFT_CMD_DELAY, //Exit Sleep 120, 0x29, 0, //Display on }; // Initialization commands for 7735B screens // ------------------------------------ static const uint8_t STP7735_init[] = { 16, // 16 commands in list TFT_CMD_PIXFMT, 1+TFT_CMD_DELAY, // 3: Set color mode, 1 arg + delay: 0x06, // 18-bit color 6-6-6 color format 10, // 10 ms delay ST7735_FRMCTR1, 3+TFT_CMD_DELAY, // 4: Frame rate control, 3 args + delay: 0x00, // fastest refresh 0x06, // 6 lines front porch 0x03, // 3 lines back porch 10, // 10 ms delay TFT_MADCTL , 1 , // 5: Memory access ctrl (directions), 1 arg: 0x08, // Row addr/col addr, bottom to top refresh ST7735_DISSET5, 2 , // 6: Display settings #5, 2 args, no delay: 0x15, // 1 clk cycle nonoverlap, 2 cycle gate // rise, 3 cycle osc equalize 0x02, // Fix on VTL ST7735_INVCTR , 1 , // 7: Display inversion control, 1 arg: 0x0, // Line inversion ST7735_PWCTR1 , 2+TFT_CMD_DELAY, // 8: Power control, 2 args + delay: 0x02, // GVDD = 4.7V 0x70, // 1.0uA 10, // 10 ms delay ST7735_PWCTR2 , 1 , // 9: Power control, 1 arg, no delay: 0x05, // VGH = 14.7V, VGL = -7.35V ST7735_PWCTR3 , 2 , // 10: Power control, 2 args, no delay: 0x01, // Opamp current small 0x02, // Boost frequency ST7735_VMCTR1 , 2+TFT_CMD_DELAY, // 11: Power control, 2 args + delay: 0x3C, // VCOMH = 4V 0x38, // VCOML = -1.1V 10, // 10 ms delay ST7735_PWCTR6 , 2 , // 12: Power control, 2 args, no delay: 0x11, 0x15, ST7735_GMCTRP1,16 , // 13: Magical unicorn dust, 16 args, no delay: 0x09, 0x16, 0x09, 0x20, // (seriously though, not sure what 0x21, 0x1B, 0x13, 0x19, // these config values represent) 0x17, 0x15, 0x1E, 0x2B, 0x04, 0x05, 0x02, 0x0E, ST7735_GMCTRN1,16+TFT_CMD_DELAY, // 14: Sparkles and rainbows, 16 args + delay: 0x0B, 0x14, 0x08, 0x1E, // (ditto) 0x22, 0x1D, 0x18, 0x1E, 0x1B, 0x1A, 0x24, 0x2B, 0x06, 0x06, 0x02, 0x0F, 10, // 10 ms delay TFT_CASET , 4 , // 15: Column addr set, 4 args, no delay: 0x00, 0x02, // XSTART = 2 0x00, 0x81, // XEND = 129 TFT_PASET , 4 , // 16: Row addr set, 4 args, no delay: 0x00, 0x02, // XSTART = 1 0x00, 0x81, // XEND = 160 ST7735_NORON , TFT_CMD_DELAY, // 17: Normal display on, no args, w/delay 10, // 10 ms delay TFT_DISPON , TFT_CMD_DELAY, // 18: Main screen turn on, no args, w/delay 255 // 255 = 500 ms delay }; // Init for 7735R, part 1 (red or green tab) // -------------------------------------- static const uint8_t STP7735R_init[] = { 14, // 14 commands in list ST7735_SLPOUT , TFT_CMD_DELAY, // 2: Out of sleep mode, 0 args, w/delay 255, // 500 ms delay ST7735_FRMCTR1, 3 , // 3: Frame rate ctrl - normal mode, 3 args: 0x01, 0x2C, 0x2D, // Rate = fosc/(1x2+40) * (LINE+2C+2D) ST7735_FRMCTR2, 3 , // 4: Frame rate control - idle mode, 3 args: 0x01, 0x2C, 0x2D, // Rate = fosc/(1x2+40) * (LINE+2C+2D) ST7735_FRMCTR3, 6 , // 5: Frame rate ctrl - partial mode, 6 args: 0x01, 0x2C, 0x2D, // Dot inversion mode 0x01, 0x2C, 0x2D, // Line inversion mode ST7735_INVCTR , 1 , // 6: Display inversion ctrl, 1 arg, no delay: 0x07, // No inversion ST7735_PWCTR1 , 3 , // 7: Power control, 3 args, no delay: 0xA2, 0x02, // -4.6V 0x84, // AUTO mode ST7735_PWCTR2 , 1 , // 8: Power control, 1 arg, no delay: 0xC5, // VGH25 = 2.4C VGSEL = -10 VGH = 3 * AVDD ST7735_PWCTR3 , 2 , // 9: Power control, 2 args, no delay: 0x0A, // Opamp current small 0x00, // Boost frequency ST7735_PWCTR4 , 2 , // 10: Power control, 2 args, no delay: 0x8A, // BCLK/2, Opamp current small & Medium low 0x2A, ST7735_PWCTR5 , 2 , // 11: Power control, 2 args, no delay: 0x8A, 0xEE, ST7735_VMCTR1 , 1 , // 12: Power control, 1 arg, no delay: 0x0E, TFT_INVOFF , 0 , // 13: Don't invert display, no args, no delay TFT_MADCTL , 1 , // 14: Memory access control (directions), 1 arg: 0xC0, // row addr/col addr, bottom to top refresh, RGB order TFT_CMD_PIXFMT , 1+TFT_CMD_DELAY, // 15: Set color mode, 1 arg + delay: 0x06, // 18-bit color 6-6-6 color format 10 // 10 ms delay }; // Init for 7735R, part 2 (green tab only) // --------------------------------------- static const uint8_t Rcmd2green[] = { 2, // 2 commands in list: TFT_CASET , 4 , // 1: Column addr set, 4 args, no delay: 0x00, 0x02, // XSTART = 0 0x00, 0x7F+0x02, // XEND = 129 TFT_PASET , 4 , // 2: Row addr set, 4 args, no delay: 0x00, 0x01, // XSTART = 0 0x00, 0x9F+0x01 // XEND = 160 }; // Init for 7735R, part 2 (red tab only) // ------------------------------------- static const uint8_t Rcmd2red[] = { 2, // 2 commands in list: TFT_CASET , 4 , // 1: Column addr set, 4 args, no delay: 0x00, 0x00, // XSTART = 0 0x00, 0x7F, // XEND = 127 TFT_PASET , 4 , // 2: Row addr set, 4 args, no delay: 0x00, 0x00, // XSTART = 0 0x00, 0x9F // XEND = 159 }; // Init for 7735R, part 3 (red or green tab) // ----------------------------------------- static const uint8_t Rcmd3[] = { 4, // 4 commands in list: ST7735_GMCTRP1, 16 , // 1: Magical unicorn dust, 16 args, no delay: 0x02, 0x1c, 0x07, 0x12, 0x37, 0x32, 0x29, 0x2d, 0x29, 0x25, 0x2B, 0x39, 0x00, 0x01, 0x03, 0x10, ST7735_GMCTRN1, 16 , // 2: Sparkles and rainbows, 16 args, no delay: 0x03, 0x1d, 0x07, 0x06, 0x2E, 0x2C, 0x29, 0x2D, 0x2E, 0x2E, 0x37, 0x3F, 0x00, 0x00, 0x02, 0x10, ST7735_NORON , TFT_CMD_DELAY, // 3: Normal display on, no args, w/delay 10, // 10 ms delay TFT_DISPON , TFT_CMD_DELAY, // 4: Main screen turn on, no args w/delay 100 // 100 ms delay }; // ==== Public functions ========================================================= // == Low level functions; usually not used directly == esp_err_t wait_trans_finish(uint8_t free_line); void disp_spi_transfer_cmd(int8_t cmd); void disp_spi_transfer_data(uint8_t *data, uint32_t len); void disp_spi_transfer_cmd_data(int8_t cmd, uint8_t *data, uint32_t len); void drawPixel(int16_t x, int16_t y, color_t color, uint8_t sel); void send_data(int x1, int y1, int x2, int y2, uint32_t len, color_t *buf, uint8_t wait); void TFT_pushColorRep(int x1, int y1, int x2, int y2, color_t data, uint32_t len); int read_data(int x1, int y1, int x2, int y2, int len, uint8_t *buf, uint8_t set_sp); uint32_t read_cmd(uint8_t cmd, uint8_t len); color_t readPixel(int16_t x, int16_t y); int touch_get_data(uint8_t type); void bcklOn(display_config_t *dconfig); void bcklOff(display_config_t *dconfig); void TFT_display_setvars(display_config_t *dconfig); void _tft_setBitsPerColor(uint8_t bitsperc); // Deactivate display's CS line //======================== esp_err_t disp_deselect(); // Activate display's CS line and configure SPI interface if necessary //====================== esp_err_t disp_select(); // Find maximum spi clock for successful read from display RAM // ** Must be used AFTER the display is initialized ** //====================== uint32_t find_rd_speed(); // Change the screen rotation. // Input: m new rotation value (0 to 3) //================================= void _tft_setRotation(uint8_t rot); // Perform display initialization sequence // Sets orientation to landscape; clears the screen //============================================================ esp_err_t TFT_display_init(display_config_t *display_config); uint16_t color16(color_t color); void disp_spi_transfer_addrwin(uint16_t x1, uint16_t x2, uint16_t y1, uint16_t y2); //=================== void stmpe610_Init(); //============================================================ int stmpe610_get_touch(uint16_t *x, uint16_t *y, uint16_t *z); //======================== uint32_t stmpe610_getID(); // =============================================================================== #endif // CONFIG_MICROPY_USE_TFT
YifuLiu/AliOS-Things
components/py_engine/modules/display/esp32/tft/tftspi.h
C
apache-2.0
20,322
#include "tftspi_hal.h" #include "soc/spi_reg.h" #include "esp_log.h" #include "freertos/task.h" #include "stdatomic.h" #include "driver/gpio.h" #include "string.h" #include "stdatomic.h" // SPI bus configuration is used by generic SPI, Display and SDCard SPI #if CONFIG_SPIRAM_SPEED_80M static spi_bus_config_t HSPI_buscfg = {-1, -1, -1, -1, -1, 0, 0, 0}; spi_bus_config_t *SPIbus_configs[3] = {NULL, &HSPI_buscfg, NULL, 0}; #else static spi_bus_config_t HSPI_buscfg = {-1, -1, -1, -1, -1, 0, 0, 0}; static spi_bus_config_t VSPI_buscfg = {-1, -1, -1, -1, -1, 0, 0, 0}; spi_bus_config_t *SPIbus_configs[3] = {NULL, &HSPI_buscfg, &VSPI_buscfg}; #endif QueueHandle_t spi_utils_mutex = NULL; // static const char TAG[] = "[SPI_UTILS]"; void transfer_test(exspi_device_handle_t *spidev); void __attribute__((weak)) IRAM_ATTR tft_spi_post_cb(spi_transaction_t *trans) { } void IRAM_ATTR spi_post_cb(spi_transaction_t *trans) { tft_spi_post_cb(trans); } esp_err_t spi_device_init(exspi_device_handle_t *spidev) { esp_err_t ret; spidev->devcfg.post_cb = spi_post_cb; ret = spi_bus_initialize(spidev->spihost, spidev->buscfg, spidev->dma_channel); ret |= spi_bus_add_device(spidev->spihost, &spidev->devcfg, &spidev->handle); if (spi_lock == NULL) { spi_lock = xSemaphoreCreateMutex(); } return ret; } //------------------------------------------------------------------- esp_err_t spi_device_select(exspi_device_handle_t *spidev, int force) { if (spidev->handle == NULL) return ESP_ERR_INVALID_ARG; while (spidev->handle->host->hal.hw->cmd.usr) ; // printf("--deselect enter --\r\n"); xSemaphoreTake(spi_lock, portMAX_DELAY); spi_device_acquire_bus(spidev->handle, portMAX_DELAY); // ESP_EARLY_LOGE("T", "enter"); return ESP_OK; } //---------------------------------------------------------- esp_err_t spi_device_deselect(exspi_device_handle_t *spidev) { if (spidev->handle == NULL) return ESP_ERR_INVALID_ARG; while (spidev->handle->host->hal.hw->cmd.usr) ; spi_device_release_bus(spidev->handle); xSemaphoreGive(spi_lock); // printf("--deselect exit --\r\n"); // ESP_EARLY_LOGE("T", "exit"); return ESP_OK; } esp_err_t spi_device_deselect_isr(exspi_device_handle_t *spidev) { static BaseType_t xHigherPriorityTaskWoken; if (spidev->handle == NULL) return ESP_ERR_INVALID_ARG; while (spidev->handle->host->hal.hw->cmd.usr) ; spi_device_release_bus(spidev->handle); xSemaphoreGiveFromISR(spi_lock, &xHigherPriorityTaskWoken); // printf("-- exit --\r\n"); // ESP_EARLY_LOGE("T", "exit"); return ESP_OK; } void IRAM_ATTR spi_transfer_cmd(exspi_device_handle_t *spidev, const uint8_t cmd) { while (spidev->handle->host->hal.hw->cmd.usr) ; // Wait for SPI bus ready spidev->handle->host->hal.hw->data_buf[0] = (uint32_t)cmd; gpio_set_level(spidev->dc, 0); _spi_transfer_start(spidev, 8, 0); } void IRAM_ATTR spi_transfer_cmd_data(exspi_device_handle_t *spidev, const uint8_t cmd, uint8_t *data, int len) { while (spidev->handle->host->hal.hw->cmd.usr) ; // Wait for SPI bus ready gpio_set_level(spidev->dc, 0); spidev->handle->host->hal.hw->data_buf[0] = (uint32_t)cmd; _spi_transfer_start(spidev, 8, 0); while (spidev->handle->host->hal.hw->cmd.usr) ; // Wait for SPI bus ready gpio_set_level(spidev->dc, 1); uint8_t idx = 0, bidx = 0; uint32_t bits = 0; uint32_t count = 0; uint32_t wd = 0; while (count < len) { // get data byte from buffer, fill spi buffer wd |= (uint32_t)data[count] << bidx; count++; bits += 8; bidx += 8; if (count == len) { while (spidev->handle->host->hal.hw->cmd.usr) { }; // Wait for SPI bus ready spidev->handle->host->hal.hw->data_buf[idx] = wd; break; } if (bidx == 32) { while (spidev->handle->host->hal.hw->cmd.usr) { }; // Wait for SPI bus ready spidev->handle->host->hal.hw->data_buf[idx] = wd; idx++; bidx = 0; wd = 0; } if (idx == 16) { // SPI buffer full, send data _spi_transfer_start(spidev, bits, 0); bits = 0; idx = 0; bidx = 0; } } if (bits > 0) _spi_transfer_start(spidev, bits, 0); } void IRAM_ATTR spi_transfer_data(exspi_device_handle_t *spidev, uint8_t *data, int len) { while (spidev->handle->host->hal.hw->cmd.usr) ; // Wait for SPI bus ready gpio_set_level(spidev->dc, 1); uint8_t idx = 0, bidx = 0; uint32_t bits = 0; uint32_t count = 0; uint32_t wd = 0; while (count < len) { // get data byte from buffer, fill spi buffer wd |= (uint32_t)data[count] << bidx; count++; bits += 8; bidx += 8; if (count == len) { while (spidev->handle->host->hal.hw->cmd.usr) { }; // Wait for SPI bus ready spidev->handle->host->hal.hw->data_buf[idx] = wd; break; } if (bidx == 32) { while (spidev->handle->host->hal.hw->cmd.usr) { }; // Wait for SPI bus ready spidev->handle->host->hal.hw->data_buf[idx] = wd; idx++; bidx = 0; wd = 0; } if (idx == 16) { // SPI buffer full, send data _spi_transfer_start(spidev, bits, 0); bits = 0; idx = 0; bidx = 0; } } if (bits > 0) _spi_transfer_start(spidev, bits, 0); } // ----------------------------- // Direct (no DMA) data transfer //---------------------------------------------------------------------------------------- esp_err_t spi_transfer_data_nodma(exspi_device_handle_t *spidev, spi_transaction_t *trans) { if (!spidev->handle) return ESP_ERR_INVALID_ARG; gpio_set_level(spidev->dc, 1); esp_err_t ret = spi_device_polling_transmit(spidev->handle, trans); return ret; } //--------------------------------------------------- uint32_t spi_get_speed(exspi_device_handle_t *spidev) { if (spidev->handle == NULL) return 0; return 0xffffffff; } //------------------------------------------------------------------- uint32_t spi_set_speed(exspi_device_handle_t *spidev, uint32_t speed) { if (spidev->handle == NULL) return 0; return ESP_OK; } // Start hardware SPI data transfer, spi device must be selected // No address or command phase is executed //---------------------------------------------------------------------------------------- void IRAM_ATTR _spi_transfer_start(exspi_device_handle_t *spidev, int wrbits, int rdbits) { if (spidev->handle == NULL) return; while (spidev->handle->host->hal.hw->cmd.usr) ; // Wait for SPI bus ready // Wait for SPI bus ready spidev->handle->host->hal.hw->user1.usr_addr_bitlen = 0; spidev->handle->host->hal.hw->user2.usr_command_bitlen = 0; spidev->handle->host->hal.hw->user.usr_addr = 0; spidev->handle->host->hal.hw->user.usr_command = 0; spidev->handle->host->hal.hw->user.usr_mosi_highpart = 0; // tx enable spidev->handle->host->hal.hw->mosi_dlen.usr_mosi_dbitlen = wrbits - 1; spidev->handle->host->hal.hw->user.usr_mosi = 1; // rx disable spidev->handle->host->hal.hw->miso_dlen.usr_miso_dbitlen = 0; spidev->handle->host->hal.hw->user.usr_miso = 0; spidev->handle->host->hal.hw->user.usr_miso_highpart = 0; // Start transfer spidev->handle->host->hal.hw->cmd.usr = 1; } //----------------------------------------------------------------------------------- void IRAM_ATTR _dma_send(exspi_device_handle_t *spidev, uint8_t *data, uint32_t size) { if (spidev->handle == NULL) return; while (spidev->handle->host->hal.hw->cmd.usr) ; // Wait for SPI bus ready gpio_set_level(spidev->dc, 1); spicommon_dmaworkaround_idle(spidev->dma_channel); // Reset DMA spidev->handle->host->hal.hw->dma_conf.val |= SPI_OUT_RST | SPI_IN_RST | SPI_AHBM_RST | SPI_AHBM_FIFO_RST; spidev->handle->host->hal.hw->dma_out_link.start = 0; spidev->handle->host->hal.hw->dma_in_link.start = 0; spidev->handle->host->hal.hw->dma_conf.val &= ~(SPI_OUT_RST | SPI_IN_RST | SPI_AHBM_RST | SPI_AHBM_FIFO_RST); spidev->handle->host->hal.hw->dma_conf.out_data_burst_en = 1; lldesc_setup_link(spidev->handle->host->hal.dmadesc_tx, data, size, false); spidev->handle->host->hal.hw->user.usr_addr = 0; spidev->handle->host->hal.hw->user.usr_command = 0; spidev->handle->host->hal.hw->user.usr_mosi_highpart = 0; spidev->handle->host->hal.hw->dma_out_link.addr = (int)(&spidev->handle->host->hal.dmadesc_tx[0]) & 0xFFFFF; spidev->handle->host->hal.hw->dma_out_link.start = 1; spidev->handle->host->hal.hw->user.usr_mosi_highpart = 0; spidev->handle->host->hal.hw->mosi_dlen.usr_mosi_dbitlen = (size * 8) - 1; spidev->handle->host->hal.hw->cmd.usr = 1; } //-------------------------------------------------------------------- esp_err_t IRAM_ATTR _wait_trans_finish(exspi_device_handle_t *spidev) { if (spidev->handle == NULL) return ESP_OK; uint32_t err = 0; while (spidev->handle->host->hal.hw->cmd.usr) ; // Wait for SPI bus ready return err; } // static esp_err_t poll_busy(exspi_device_handle_t *spidev) { // uint8_t t_rx; // t_rx = 0xaa; // spi_transaction_t t = { // .tx_buffer = &t_rx, // .flags = SPI_TRANS_USE_RXDATA, //data stored in rx_data // .length = 8, // }; // esp_err_t ret; // t.rx_data[0] = 0; // ret = spi_device_polling_transmit(spidev->handle, &t); // return ret; // } // void test2(exspi_device_handle_t *spidev) { // poll_busy(spidev,) // uint8_t* buf = (uint8_t *)malloc(20 * sizeof(uint8_t *)); // memset(buf, 0xaa, 20); // uint8_t cmd[20] = {0x55, 0xaa, 0x55}; // esp_err_t ret; // spi_transaction_t t; // memset(&t, 0, sizeof(t)); //Zero out the transaction // t.flags = 0; // t.rx_buffer = buf; // t.tx_buffer = cmd; // t.rxlength = 16 * 8; // t.length = 16 * 8; //Command is 8 bits // ret=spi_device_polling_transmit(spidev->handle, &t); //Transmit! // assert(ret==ESP_OK); //Should have had no issues. // ESP_LOG_BUFFER_HEX_LEVEL("SPI_TEST", buf, 16, ESP_LOG_INFO); // free(buf); // vTaskDelay(pdMS_TO_TICKS(1000)); // } // void transfer_test(exspi_device_handle_t *spidev) { // uint8_t test[] = {0x11, 0xaa, 0x55}; // spi_device_acquire_bus(spidev->handle, portMAX_DELAY); // spi_transfer_cmd_data(spidev, 0x01, test, 3); // _wait_trans_finish(spidev); // spi_device_release_bus(spidev->handle); // for (uint8_t i = 0; i < 1; i++) { // spi_device_acquire_bus(spidev->handle, portMAX_DELAY); // test2(spidev); // spi_device_release_bus(spidev->handle); // } // }
YifuLiu/AliOS-Things
components/py_engine/modules/display/esp32/tft/tftspi_hal.c
C
apache-2.0
11,277
#ifndef _DRIVER_TFT_SPI_HAL_H_ #define _DRIVER_TFT_SPI_HAL_H_ #include "driver/spi_master.h" #include "freertos/queue.h" #include "hal/spi_hal.h" #include "driver/spi_common_internal.h" #include "hal/spi_hal.h" #include "hal/spi_ll.h" #include "freertos/semphr.h" typedef struct { spi_transaction_t *trans; const uint32_t *buffer_to_send; //equals to tx_data, if SPI_TRANS_USE_RXDATA is applied; otherwise if original buffer wasn't in DMA-capable memory, this gets the address of a temporary buffer that is; //otherwise sets to the original buffer or NULL if no buffer is assigned. uint32_t *buffer_to_rcv; // similar to buffer_to_send } spi_trans_priv_t; typedef struct spi_device_t spi_device_t; static SemaphoreHandle_t spi_lock = NULL; typedef struct { int id; spi_device_t* device[DEV_NUM_MAX]; intr_handle_t intr; spi_hal_context_t hal; spi_trans_priv_t cur_trans_buf; int cur_cs; //current device doing transaction const spi_bus_attr_t* bus_attr; /** * the bus is permanently controlled by a device until `spi_bus_release_bus`` is called. Otherwise * the acquiring of SPI bus will be freed when `spi_device_polling_end` is called. */ spi_device_t* device_acquiring_lock; //debug information bool polling; //in process of a polling, avoid of queue new transactions into ISR } spi_host_t; struct spi_device_t { int id; QueueHandle_t trans_queue; QueueHandle_t ret_queue; spi_device_interface_config_t cfg; spi_hal_timing_conf_t timing_conf; spi_host_t *host; spi_bus_lock_dev_handle_t dev_lock; }; typedef struct { spi_device_handle_t handle; int8_t cs; int8_t dc; uint8_t selected; uint8_t spihost; uint8_t dma_channel; uint32_t curr_clock; spi_bus_config_t *buscfg; spi_device_interface_config_t devcfg; } exspi_device_handle_t; #define SPI_SEMAPHORE_WAIT 2000 // Time in ms to wait for SPI mutex #define SDSPI_HOST_ID -2 // sdspi ID #define TOTAL_CS (NO_CS*2) extern spi_bus_config_t *SPIbus_configs[3]; extern QueueHandle_t spi_utils_mutex; esp_err_t spi_device_init(exspi_device_handle_t *spidev); esp_err_t spi_device_select(exspi_device_handle_t *spidev, int force); esp_err_t spi_device_deselect(exspi_device_handle_t *spidev); void spi_transfer_cmd(exspi_device_handle_t *spidev, const uint8_t cmd); void spi_transfer_cmd_data(exspi_device_handle_t *spidev, const uint8_t cmd, uint8_t* data, int len); void spi_transfer_data(exspi_device_handle_t *spidev, uint8_t* data, int len); esp_err_t spi_transfer_data_nodma(exspi_device_handle_t *spidev, spi_transaction_t *trans); uint32_t spi_get_speed(exspi_device_handle_t *spidev); uint32_t spi_set_speed(exspi_device_handle_t *spidev, uint32_t speed); void _spi_transfer_start(exspi_device_handle_t *spi_dev, int wrbits, int rdbits); void _dma_send(exspi_device_handle_t *spi_dev, uint8_t *data, uint32_t size); esp_err_t _wait_trans_finish(exspi_device_handle_t *spi_dev); #endif
YifuLiu/AliOS-Things
components/py_engine/modules/display/esp32/tft/tftspi_hal.h
C
apache-2.0
3,228
/*----------------------------------------------------------------------------/ / TJpgDec - Tiny JPEG Decompressor R0.03 (C)ChaN, 2021 /-----------------------------------------------------------------------------/ / The TJpgDec is a generic JPEG decompressor module for tiny embedded systems. / This is a free software that opened for education, research and commercial / developments under license policy of following terms. / / Copyright (C) 2021, ChaN, all right reserved. / / * The TJpgDec module is a free software and there is NO WARRANTY. / * No restriction on use. You can use, modify and redistribute it for / personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY. / * Redistributions of source code must retain the above copyright notice. / /-----------------------------------------------------------------------------/ / Oct 04, 2011 R0.01 First release. / Feb 19, 2012 R0.01a Fixed decompression fails when scan starts with an escape seq. / Sep 03, 2012 R0.01b Added JD_TBLCLIP option. / Mar 16, 2019 R0.01c Supprted stdint.h. / Jul 01, 2020 R0.01d Fixed wrong integer type usage. / May 08, 2021 R0.02 Supprted grayscale image. Separated configuration options. / Jun 11, 2021 R0.02a Some performance improvement. / Jul 01, 2021 R0.03 Added JD_FASTDECODE option. / Some performance improvement. /----------------------------------------------------------------------------*/ #include "tjpgd.h" #if JD_FASTDECODE == 2 #define HUFF_BIT 10 /* Bit length to apply fast huffman decode */ #define HUFF_LEN (1 << HUFF_BIT) #define HUFF_MASK (HUFF_LEN - 1) #endif /*-----------------------------------------------*/ /* Zigzag-order to raster-order conversion table */ /*-----------------------------------------------*/ static const uint8_t Zig[64] = { /* Zigzag-order to raster-order conversion table */ 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51, 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63 }; /*-------------------------------------------------*/ /* Input scale factor of Arai algorithm */ /* (scaled up 16 bits for fixed point operations) */ /*-------------------------------------------------*/ static const uint16_t Ipsf[64] = { /* See also aa_idct.png */ (uint16_t)(1.00000*8192), (uint16_t)(1.38704*8192), (uint16_t)(1.30656*8192), (uint16_t)(1.17588*8192), (uint16_t)(1.00000*8192), (uint16_t)(0.78570*8192), (uint16_t)(0.54120*8192), (uint16_t)(0.27590*8192), (uint16_t)(1.38704*8192), (uint16_t)(1.92388*8192), (uint16_t)(1.81226*8192), (uint16_t)(1.63099*8192), (uint16_t)(1.38704*8192), (uint16_t)(1.08979*8192), (uint16_t)(0.75066*8192), (uint16_t)(0.38268*8192), (uint16_t)(1.30656*8192), (uint16_t)(1.81226*8192), (uint16_t)(1.70711*8192), (uint16_t)(1.53636*8192), (uint16_t)(1.30656*8192), (uint16_t)(1.02656*8192), (uint16_t)(0.70711*8192), (uint16_t)(0.36048*8192), (uint16_t)(1.17588*8192), (uint16_t)(1.63099*8192), (uint16_t)(1.53636*8192), (uint16_t)(1.38268*8192), (uint16_t)(1.17588*8192), (uint16_t)(0.92388*8192), (uint16_t)(0.63638*8192), (uint16_t)(0.32442*8192), (uint16_t)(1.00000*8192), (uint16_t)(1.38704*8192), (uint16_t)(1.30656*8192), (uint16_t)(1.17588*8192), (uint16_t)(1.00000*8192), (uint16_t)(0.78570*8192), (uint16_t)(0.54120*8192), (uint16_t)(0.27590*8192), (uint16_t)(0.78570*8192), (uint16_t)(1.08979*8192), (uint16_t)(1.02656*8192), (uint16_t)(0.92388*8192), (uint16_t)(0.78570*8192), (uint16_t)(0.61732*8192), (uint16_t)(0.42522*8192), (uint16_t)(0.21677*8192), (uint16_t)(0.54120*8192), (uint16_t)(0.75066*8192), (uint16_t)(0.70711*8192), (uint16_t)(0.63638*8192), (uint16_t)(0.54120*8192), (uint16_t)(0.42522*8192), (uint16_t)(0.29290*8192), (uint16_t)(0.14932*8192), (uint16_t)(0.27590*8192), (uint16_t)(0.38268*8192), (uint16_t)(0.36048*8192), (uint16_t)(0.32442*8192), (uint16_t)(0.27590*8192), (uint16_t)(0.21678*8192), (uint16_t)(0.14932*8192), (uint16_t)(0.07612*8192) }; /*---------------------------------------------*/ /* Conversion table for fast clipping process */ /*---------------------------------------------*/ #if JD_TBLCLIP #define BYTECLIP(v) Clip8[(unsigned int)(v) & 0x3FF] static const uint8_t Clip8[1024] = { /* 0..255 */ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, /* 256..511 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, /* -512..-257 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* -256..-1 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; #else /* JD_TBLCLIP */ static uint8_t BYTECLIP (int val) { if (val < 0) return 0; if (val > 255) return 255; return (uint8_t)val; } #endif /*-----------------------------------------------------------------------*/ /* Allocate a memory block from memory pool */ /*-----------------------------------------------------------------------*/ static void* alloc_pool ( /* Pointer to allocated memory block (NULL:no memory available) */ JDEC* jd, /* Pointer to the decompressor object */ size_t ndata /* Number of bytes to allocate */ ) { char *rp = 0; ndata = (ndata + 3) & ~3; /* Align block size to the word boundary */ if (jd->sz_pool >= ndata) { jd->sz_pool -= ndata; rp = (char*)jd->pool; /* Get start of available memory pool */ jd->pool = (void*)(rp + ndata); /* Allocate requierd bytes */ } return (void*)rp; /* Return allocated memory block (NULL:no memory to allocate) */ } /*-----------------------------------------------------------------------*/ /* Create de-quantization and prescaling tables with a DQT segment */ /*-----------------------------------------------------------------------*/ static JRESULT create_qt_tbl ( /* 0:OK, !0:Failed */ JDEC* jd, /* Pointer to the decompressor object */ const uint8_t* data, /* Pointer to the quantizer tables */ size_t ndata /* Size of input data */ ) { unsigned int i, zi; uint8_t d; int32_t *pb; while (ndata) { /* Process all tables in the segment */ if (ndata < 65) return JDR_FMT1; /* Err: table size is unaligned */ ndata -= 65; d = *data++; /* Get table property */ if (d & 0xF0) return JDR_FMT1; /* Err: not 8-bit resolution */ i = d & 3; /* Get table ID */ pb = alloc_pool(jd, 64 * sizeof (int32_t));/* Allocate a memory block for the table */ if (!pb) return JDR_MEM1; /* Err: not enough memory */ jd->qttbl[i] = pb; /* Register the table */ for (i = 0; i < 64; i++) { /* Load the table */ zi = Zig[i]; /* Zigzag-order to raster-order conversion */ pb[zi] = (int32_t)((uint32_t)*data++ * Ipsf[zi]); /* Apply scale factor of Arai algorithm to the de-quantizers */ } } return JDR_OK; } /*-----------------------------------------------------------------------*/ /* Create huffman code tables with a DHT segment */ /*-----------------------------------------------------------------------*/ static JRESULT create_huffman_tbl ( /* 0:OK, !0:Failed */ JDEC* jd, /* Pointer to the decompressor object */ const uint8_t* data, /* Pointer to the packed huffman tables */ size_t ndata /* Size of input data */ ) { unsigned int i, j, b, cls, num; size_t np; uint8_t d, *pb, *pd; uint16_t hc, *ph; while (ndata) { /* Process all tables in the segment */ if (ndata < 17) return JDR_FMT1; /* Err: wrong data size */ ndata -= 17; d = *data++; /* Get table number and class */ if (d & 0xEE) return JDR_FMT1; /* Err: invalid class/number */ cls = d >> 4; num = d & 0x0F; /* class = dc(0)/ac(1), table number = 0/1 */ pb = alloc_pool(jd, 16); /* Allocate a memory block for the bit distribution table */ if (!pb) return JDR_MEM1; /* Err: not enough memory */ jd->huffbits[num][cls] = pb; for (np = i = 0; i < 16; i++) { /* Load number of patterns for 1 to 16-bit code */ np += (pb[i] = *data++); /* Get sum of code words for each code */ } ph = alloc_pool(jd, np * sizeof (uint16_t));/* Allocate a memory block for the code word table */ if (!ph) return JDR_MEM1; /* Err: not enough memory */ jd->huffcode[num][cls] = ph; hc = 0; for (j = i = 0; i < 16; i++) { /* Re-build huffman code word table */ b = pb[i]; while (b--) ph[j++] = hc++; hc <<= 1; } if (ndata < np) return JDR_FMT1; /* Err: wrong data size */ ndata -= np; pd = alloc_pool(jd, np); /* Allocate a memory block for the decoded data */ if (!pd) return JDR_MEM1; /* Err: not enough memory */ jd->huffdata[num][cls] = pd; for (i = 0; i < np; i++) { /* Load decoded data corresponds to each code word */ d = *data++; if (!cls && d > 11) return JDR_FMT1; pd[i] = d; } #if JD_FASTDECODE == 2 { /* Create fast huffman decode table */ unsigned int span, td, ti; uint16_t *tbl_ac = 0; uint8_t *tbl_dc = 0; if (cls) { tbl_ac = alloc_pool(jd, HUFF_LEN * sizeof (uint16_t)); /* LUT for AC elements */ if (!tbl_ac) return JDR_MEM1; /* Err: not enough memory */ jd->hufflut_ac[num] = tbl_ac; memset(tbl_ac, 0xFF, HUFF_LEN * sizeof (uint16_t)); /* Default value (0xFFFF: may be long code) */ } else { tbl_dc = alloc_pool(jd, HUFF_LEN * sizeof (uint8_t)); /* LUT for AC elements */ if (!tbl_dc) return JDR_MEM1; /* Err: not enough memory */ jd->hufflut_dc[num] = tbl_dc; memset(tbl_dc, 0xFF, HUFF_LEN * sizeof (uint8_t)); /* Default value (0xFF: may be long code) */ } for (i = b = 0; b < HUFF_BIT; b++) { /* Create LUT */ for (j = pb[b]; j; j--) { ti = ph[i] << (HUFF_BIT - 1 - b) & HUFF_MASK; /* Index of input pattern for the code */ if (cls) { td = pd[i++] | ((b + 1) << 8); /* b15..b8: code length, b7..b0: zero run and data length */ for (span = 1 << (HUFF_BIT - 1 - b); span; span--, tbl_ac[ti++] = (uint16_t)td) ; } else { td = pd[i++] | ((b + 1) << 4); /* b7..b4: code length, b3..b0: data length */ for (span = 1 << (HUFF_BIT - 1 - b); span; span--, tbl_dc[ti++] = (uint8_t)td) ; } } } jd->longofs[num][cls] = i; /* Code table offset for long code */ } #endif } return JDR_OK; } /*-----------------------------------------------------------------------*/ /* Extract a huffman decoded data from input stream */ /*-----------------------------------------------------------------------*/ static int huffext ( /* >=0: decoded data, <0: error code */ JDEC* jd, /* Pointer to the decompressor object */ unsigned int id, /* Table ID (0:Y, 1:C) */ unsigned int cls /* Table class (0:DC, 1:AC) */ ) { size_t dc = jd->dctr; uint8_t *dp = jd->dptr; unsigned int d, flg = 0; #if JD_FASTDECODE == 0 uint8_t bm, nd, bl; const uint8_t *hb = jd->huffbits[id][cls]; /* Bit distribution table */ const uint16_t *hc = jd->huffcode[id][cls]; /* Code word table */ const uint8_t *hd = jd->huffdata[id][cls]; /* Data table */ bm = jd->dbit; /* Bit mask to extract */ d = 0; bl = 16; /* Max code length */ do { if (!bm) { /* Next byte? */ if (!dc) { /* No input data is available, re-fill input buffer */ dp = jd->inbuf; /* Top of input buffer */ dc = jd->infunc(jd, dp, JD_SZBUF); if (!dc) return 0 - (int)JDR_INP; /* Err: read error or wrong stream termination */ } else { dp++; /* Next data ptr */ } dc--; /* Decrement number of available bytes */ if (flg) { /* In flag sequence? */ flg = 0; /* Exit flag sequence */ if (*dp != 0) return 0 - (int)JDR_FMT1; /* Err: unexpected flag is detected (may be collapted data) */ *dp = 0xFF; /* The flag is a data 0xFF */ } else { if (*dp == 0xFF) { /* Is start of flag sequence? */ flg = 1; continue; /* Enter flag sequence, get trailing byte */ } } bm = 0x80; /* Read from MSB */ } d <<= 1; /* Get a bit */ if (*dp & bm) d++; bm >>= 1; for (nd = *hb++; nd; nd--) { /* Search the code word in this bit length */ if (d == *hc++) { /* Matched? */ jd->dbit = bm; jd->dctr = dc; jd->dptr = dp; return *hd; /* Return the decoded data */ } hd++; } bl--; } while (bl); #else const uint8_t *hb, *hd; const uint16_t *hc; unsigned int nc, bl, wbit = jd->dbit % 32; uint32_t w = jd->wreg & ((1UL << wbit) - 1); while (wbit < 16) { /* Prepare 16 bits into the working register */ if (jd->marker) { d = 0xFF; /* Input stream has stalled for a marker. Generate stuff bits */ } else { if (!dc) { /* Buffer empty, re-fill input buffer */ dp = jd->inbuf; /* Top of input buffer */ dc = jd->infunc(jd, dp, JD_SZBUF); if (!dc) return 0 - (int)JDR_INP; /* Err: read error or wrong stream termination */ } d = *dp++; dc--; if (flg) { /* In flag sequence? */ flg = 0; /* Exit flag sequence */ if (d != 0) jd->marker = d; /* Not an escape of 0xFF but a marker */ d = 0xFF; } else { if (d == 0xFF) { /* Is start of flag sequence? */ flg = 1; continue; /* Enter flag sequence, get trailing byte */ } } } w = w << 8 | d; /* Shift 8 bits in the working register */ wbit += 8; } jd->dctr = dc; jd->dptr = dp; jd->wreg = w; #if JD_FASTDECODE == 2 /* Table serch for the short codes */ d = (unsigned int)(w >> (wbit - HUFF_BIT)); /* Short code as table index */ if (cls) { /* AC element */ d = jd->hufflut_ac[id][d]; /* Table decode */ if (d != 0xFFFF) { /* It is done if hit in short code */ jd->dbit = wbit - (d >> 8); /* Snip the code length */ return d & 0xFF; /* b7..0: zero run and following data bits */ } } else { /* DC element */ d = jd->hufflut_dc[id][d]; /* Table decode */ if (d != 0xFF) { /* It is done if hit in short code */ jd->dbit = wbit - (d >> 4); /* Snip the code length */ return d & 0xF; /* b3..0: following data bits */ } } /* Incremental serch for the codes longer than HUFF_BIT */ hb = jd->huffbits[id][cls] + HUFF_BIT; /* Bit distribution table */ hc = jd->huffcode[id][cls] + jd->longofs[id][cls]; /* Code word table */ hd = jd->huffdata[id][cls] + jd->longofs[id][cls]; /* Data table */ bl = HUFF_BIT + 1; #else /* Incremental serch for all codes */ hb = jd->huffbits[id][cls]; /* Bit distribution table */ hc = jd->huffcode[id][cls]; /* Code word table */ hd = jd->huffdata[id][cls]; /* Data table */ bl = 1; #endif for ( ; bl <= 16; bl++) { /* Incremental search */ nc = *hb++; if (nc) { d = w >> (wbit - bl); do { /* Search the code word in this bit length */ if (d == *hc++) { /* Matched? */ jd->dbit = wbit - bl; /* Snip the huffman code */ return *hd; /* Return the decoded data */ } hd++; } while (--nc); } } #endif return 0 - (int)JDR_FMT1; /* Err: code not found (may be collapted data) */ } /*-----------------------------------------------------------------------*/ /* Extract N bits from input stream */ /*-----------------------------------------------------------------------*/ static int bitext ( /* >=0: extracted data, <0: error code */ JDEC* jd, /* Pointer to the decompressor object */ unsigned int nbit /* Number of bits to extract (1 to 16) */ ) { size_t dc = jd->dctr; uint8_t *dp = jd->dptr; unsigned int d, flg = 0; #if JD_FASTDECODE == 0 uint8_t mbit = jd->dbit; d = 0; do { if (!mbit) { /* Next byte? */ if (!dc) { /* No input data is available, re-fill input buffer */ dp = jd->inbuf; /* Top of input buffer */ dc = jd->infunc(jd, dp, JD_SZBUF); if (!dc) return 0 - (int)JDR_INP; /* Err: read error or wrong stream termination */ } else { dp++; /* Next data ptr */ } dc--; /* Decrement number of available bytes */ if (flg) { /* In flag sequence? */ flg = 0; /* Exit flag sequence */ if (*dp != 0) return 0 - (int)JDR_FMT1; /* Err: unexpected flag is detected (may be collapted data) */ *dp = 0xFF; /* The flag is a data 0xFF */ } else { if (*dp == 0xFF) { /* Is start of flag sequence? */ flg = 1; continue; /* Enter flag sequence */ } } mbit = 0x80; /* Read from MSB */ } d <<= 1; /* Get a bit */ if (*dp & mbit) d |= 1; mbit >>= 1; nbit--; } while (nbit); jd->dbit = mbit; jd->dctr = dc; jd->dptr = dp; return (int)d; #else unsigned int wbit = jd->dbit % 32; uint32_t w = jd->wreg & ((1UL << wbit) - 1); while (wbit < nbit) { /* Prepare nbit bits into the working register */ if (jd->marker) { d = 0xFF; /* Input stream stalled, generate stuff bits */ } else { if (!dc) { /* Buffer empty, re-fill input buffer */ dp = jd->inbuf; /* Top of input buffer */ dc = jd->infunc(jd, dp, JD_SZBUF); if (!dc) return 0 - (int)JDR_INP; /* Err: read error or wrong stream termination */ } d = *dp++; dc--; if (flg) { /* In flag sequence? */ flg = 0; /* Exit flag sequence */ if (d != 0) jd->marker = d; /* Not an escape of 0xFF but a marker */ d = 0xFF; } else { if (d == 0xFF) { /* Is start of flag sequence? */ flg = 1; continue; /* Enter flag sequence, get trailing byte */ } } } w = w << 8 | d; /* Get 8 bits into the working register */ wbit += 8; } jd->wreg = w; jd->dbit = wbit - nbit; jd->dctr = dc; jd->dptr = dp; return (int)(w >> ((wbit - nbit) % 32)); #endif } /*-----------------------------------------------------------------------*/ /* Process restart interval */ /*-----------------------------------------------------------------------*/ static JRESULT restart ( JDEC* jd, /* Pointer to the decompressor object */ uint16_t rstn /* Expected restert sequense number */ ) { unsigned int i; uint8_t *dp = jd->dptr; size_t dc = jd->dctr; #if JD_FASTDECODE == 0 uint16_t d = 0; /* Get two bytes from the input stream */ for (i = 0; i < 2; i++) { if (!dc) { /* No input data is available, re-fill input buffer */ dp = jd->inbuf; dc = jd->infunc(jd, dp, JD_SZBUF); if (!dc) return JDR_INP; } else { dp++; } dc--; d = d << 8 | *dp; /* Get a byte */ } jd->dptr = dp; jd->dctr = dc; jd->dbit = 0; /* Check the marker */ if ((d & 0xFFD8) != 0xFFD0 || (d & 7) != (rstn & 7)) { return JDR_FMT1; /* Err: expected RSTn marker is not detected (may be collapted data) */ } #else uint16_t marker; if (jd->marker) { /* Generate a maker if it has been detected */ marker = 0xFF00 | jd->marker; jd->marker = 0; } else { marker = 0; for (i = 0; i < 2; i++) { /* Get a restart marker */ if (!dc) { /* No input data is available, re-fill input buffer */ dp = jd->inbuf; dc = jd->infunc(jd, dp, JD_SZBUF); if (!dc) return JDR_INP; } marker = (marker << 8) | *dp++; /* Get a byte */ dc--; } jd->dptr = dp; jd->dctr = dc; } /* Check the marker */ if ((marker & 0xFFD8) != 0xFFD0 || (marker & 7) != (rstn & 7)) { return JDR_FMT1; /* Err: expected RSTn marker was not detected (may be collapted data) */ } jd->dbit = 0; /* Discard stuff bits */ #endif jd->dcv[2] = jd->dcv[1] = jd->dcv[0] = 0; /* Reset DC offset */ return JDR_OK; } /*-----------------------------------------------------------------------*/ /* Apply Inverse-DCT in Arai Algorithm (see also aa_idct.png) */ /*-----------------------------------------------------------------------*/ static void block_idct ( int32_t* src, /* Input block data (de-quantized and pre-scaled for Arai Algorithm) */ jd_yuv_t* dst /* Pointer to the destination to store the block as byte array */ ) { const int32_t M13 = (int32_t)(1.41421*4096), M2 = (int32_t)(1.08239*4096), M4 = (int32_t)(2.61313*4096), M5 = (int32_t)(1.84776*4096); int32_t v0, v1, v2, v3, v4, v5, v6, v7; int32_t t10, t11, t12, t13; int i; /* Process columns */ for (i = 0; i < 8; i++) { v0 = src[8 * 0]; /* Get even elements */ v1 = src[8 * 2]; v2 = src[8 * 4]; v3 = src[8 * 6]; t10 = v0 + v2; /* Process the even elements */ t12 = v0 - v2; t11 = (v1 - v3) * M13 >> 12; v3 += v1; t11 -= v3; v0 = t10 + v3; v3 = t10 - v3; v1 = t11 + t12; v2 = t12 - t11; v4 = src[8 * 7]; /* Get odd elements */ v5 = src[8 * 1]; v6 = src[8 * 5]; v7 = src[8 * 3]; t10 = v5 - v4; /* Process the odd elements */ t11 = v5 + v4; t12 = v6 - v7; v7 += v6; v5 = (t11 - v7) * M13 >> 12; v7 += t11; t13 = (t10 + t12) * M5 >> 12; v4 = t13 - (t10 * M2 >> 12); v6 = t13 - (t12 * M4 >> 12) - v7; v5 -= v6; v4 -= v5; src[8 * 0] = v0 + v7; /* Write-back transformed values */ src[8 * 7] = v0 - v7; src[8 * 1] = v1 + v6; src[8 * 6] = v1 - v6; src[8 * 2] = v2 + v5; src[8 * 5] = v2 - v5; src[8 * 3] = v3 + v4; src[8 * 4] = v3 - v4; src++; /* Next column */ } /* Process rows */ src -= 8; for (i = 0; i < 8; i++) { v0 = src[0] + (128L << 8); /* Get even elements (remove DC offset (-128) here) */ v1 = src[2]; v2 = src[4]; v3 = src[6]; t10 = v0 + v2; /* Process the even elements */ t12 = v0 - v2; t11 = (v1 - v3) * M13 >> 12; v3 += v1; t11 -= v3; v0 = t10 + v3; v3 = t10 - v3; v1 = t11 + t12; v2 = t12 - t11; v4 = src[7]; /* Get odd elements */ v5 = src[1]; v6 = src[5]; v7 = src[3]; t10 = v5 - v4; /* Process the odd elements */ t11 = v5 + v4; t12 = v6 - v7; v7 += v6; v5 = (t11 - v7) * M13 >> 12; v7 += t11; t13 = (t10 + t12) * M5 >> 12; v4 = t13 - (t10 * M2 >> 12); v6 = t13 - (t12 * M4 >> 12) - v7; v5 -= v6; v4 -= v5; /* Descale the transformed values 8 bits and output a row */ #if JD_FASTDECODE >= 1 dst[0] = (int16_t)((v0 + v7) >> 8); dst[7] = (int16_t)((v0 - v7) >> 8); dst[1] = (int16_t)((v1 + v6) >> 8); dst[6] = (int16_t)((v1 - v6) >> 8); dst[2] = (int16_t)((v2 + v5) >> 8); dst[5] = (int16_t)((v2 - v5) >> 8); dst[3] = (int16_t)((v3 + v4) >> 8); dst[4] = (int16_t)((v3 - v4) >> 8); #else dst[0] = BYTECLIP((v0 + v7) >> 8); dst[7] = BYTECLIP((v0 - v7) >> 8); dst[1] = BYTECLIP((v1 + v6) >> 8); dst[6] = BYTECLIP((v1 - v6) >> 8); dst[2] = BYTECLIP((v2 + v5) >> 8); dst[5] = BYTECLIP((v2 - v5) >> 8); dst[3] = BYTECLIP((v3 + v4) >> 8); dst[4] = BYTECLIP((v3 - v4) >> 8); #endif dst += 8; src += 8; /* Next row */ } } /*-----------------------------------------------------------------------*/ /* Load all blocks in an MCU into working buffer */ /*-----------------------------------------------------------------------*/ static JRESULT mcu_load ( JDEC* jd /* Pointer to the decompressor object */ ) { int32_t *tmp = (int32_t*)jd->workbuf; /* Block working buffer for de-quantize and IDCT */ int d, e; unsigned int blk, nby, i, bc, z, id, cmp; jd_yuv_t *bp; const int32_t *dqf; nby = jd->msx * jd->msy; /* Number of Y blocks (1, 2 or 4) */ bp = jd->mcubuf; /* Pointer to the first block of MCU */ for (blk = 0; blk < nby + 2; blk++) { /* Get nby Y blocks and two C blocks */ cmp = (blk < nby) ? 0 : blk - nby + 1; /* Component number 0:Y, 1:Cb, 2:Cr */ if (cmp && jd->ncomp != 3) { /* Clear C blocks if not exist (monochrome image) */ for (i = 0; i < 64; bp[i++] = 128) ; } else { /* Load Y/C blocks from input stream */ id = cmp ? 1 : 0; /* Huffman table ID of this component */ /* Extract a DC element from input stream */ d = huffext(jd, id, 0); /* Extract a huffman coded data (bit length) */ if (d < 0) return (JRESULT)(0 - d); /* Err: invalid code or input */ bc = (unsigned int)d; d = jd->dcv[cmp]; /* DC value of previous block */ if (bc) { /* If there is any difference from previous block */ e = bitext(jd, bc); /* Extract data bits */ if (e < 0) return (JRESULT)(0 - e); /* Err: input */ bc = 1 << (bc - 1); /* MSB position */ if (!(e & bc)) e -= (bc << 1) - 1; /* Restore negative value if needed */ d += e; /* Get current value */ jd->dcv[cmp] = (int16_t)d; /* Save current DC value for next block */ } dqf = jd->qttbl[jd->qtid[cmp]]; /* De-quantizer table ID for this component */ tmp[0] = d * dqf[0] >> 8; /* De-quantize, apply scale factor of Arai algorithm and descale 8 bits */ /* Extract following 63 AC elements from input stream */ memset(&tmp[1], 0, 63 * sizeof (int32_t)); /* Initialize all AC elements */ z = 1; /* Top of the AC elements (in zigzag-order) */ do { d = huffext(jd, id, 1); /* Extract a huffman coded value (zero runs and bit length) */ if (d == 0) break; /* EOB? */ if (d < 0) return (JRESULT)(0 - d); /* Err: invalid code or input error */ bc = (unsigned int)d; z += bc >> 4; /* Skip leading zero run */ if (z >= 64) return JDR_FMT1; /* Too long zero run */ if (bc &= 0x0F) { /* Bit length? */ d = bitext(jd, bc); /* Extract data bits */ if (d < 0) return (JRESULT)(0 - d); /* Err: input device */ bc = 1 << (bc - 1); /* MSB position */ if (!(d & bc)) d -= (bc << 1) - 1; /* Restore negative value if needed */ i = Zig[z]; /* Get raster-order index */ tmp[i] = d * dqf[i] >> 8; /* De-quantize, apply scale factor of Arai algorithm and descale 8 bits */ } } while (++z < 64); /* Next AC element */ if (JD_FORMAT != 2 || !cmp) { /* C components may not be processed if in grayscale output */ if (z == 1 || (JD_USE_SCALE && jd->scale == 3)) { /* If no AC element or scale ratio is 1/8, IDCT can be ommited and the block is filled with DC value */ d = (jd_yuv_t)((*tmp / 256) + 128); if (JD_FASTDECODE >= 1) { for (i = 0; i < 64; bp[i++] = d) ; } else { memset(bp, d, 64); } } else { block_idct(tmp, bp); /* Apply IDCT and store the block to the MCU buffer */ } } } bp += 64; /* Next block */ } return JDR_OK; /* All blocks have been loaded successfully */ } /*-----------------------------------------------------------------------*/ /* Output an MCU: Convert YCrCb to RGB and output it in RGB form */ /*-----------------------------------------------------------------------*/ static JRESULT mcu_output ( JDEC* jd, /* Pointer to the decompressor object */ int (*outfunc)(JDEC*, void*, JRECT*), /* RGB output function */ unsigned int img_x, /* MCU location in the image */ unsigned int img_y /* MCU location in the image */ ) { const int CVACC = (sizeof (int) > 2) ? 1024 : 128; /* Adaptive accuracy for both 16-/32-bit systems */ unsigned int ix, iy, mx, my, rx, ry; int yy, cb, cr; jd_yuv_t *py, *pc; uint8_t *pix; JRECT rect; mx = jd->msx * 8; my = jd->msy * 8; /* MCU size (pixel) */ rx = (img_x + mx <= jd->width) ? mx : jd->width - img_x; /* Output rectangular size (it may be clipped at right/bottom end of image) */ ry = (img_y + my <= jd->height) ? my : jd->height - img_y; if (JD_USE_SCALE) { rx >>= jd->scale; ry >>= jd->scale; if (!rx || !ry) return JDR_OK; /* Skip this MCU if all pixel is to be rounded off */ img_x >>= jd->scale; img_y >>= jd->scale; } rect.left = img_x; rect.right = img_x + rx - 1; /* Rectangular area in the frame buffer */ rect.top = img_y; rect.bottom = img_y + ry - 1; if (!JD_USE_SCALE || jd->scale != 3) { /* Not for 1/8 scaling */ pix = (uint8_t*)jd->workbuf; if (JD_FORMAT != 2) { /* RGB output (build an RGB MCU from Y/C component) */ for (iy = 0; iy < my; iy++) { pc = py = jd->mcubuf; if (my == 16) { /* Double block height? */ pc += 64 * 4 + (iy >> 1) * 8; if (iy >= 8) py += 64; } else { /* Single block height */ pc += mx * 8 + iy * 8; } py += iy * 8; for (ix = 0; ix < mx; ix++) { cb = pc[0] - 128; /* Get Cb/Cr component and remove offset */ cr = pc[64] - 128; if (mx == 16) { /* Double block width? */ if (ix == 8) py += 64 - 8; /* Jump to next block if double block heigt */ pc += ix & 1; /* Step forward chroma pointer every two pixels */ } else { /* Single block width */ pc++; /* Step forward chroma pointer every pixel */ } yy = *py++; /* Get Y component */ *pix++ = /*R*/ BYTECLIP(yy + ((int)(1.402 * CVACC) * cr) / CVACC); *pix++ = /*G*/ BYTECLIP(yy - ((int)(0.344 * CVACC) * cb + (int)(0.714 * CVACC) * cr) / CVACC); *pix++ = /*B*/ BYTECLIP(yy + ((int)(1.772 * CVACC) * cb) / CVACC); } } } else { /* Monochrome output (build a grayscale MCU from Y comopnent) */ for (iy = 0; iy < my; iy++) { py = jd->mcubuf + iy * 8; if (my == 16) { /* Double block height? */ if (iy >= 8) py += 64; } for (ix = 0; ix < mx; ix++) { if (mx == 16) { /* Double block width? */ if (ix == 8) py += 64 - 8; /* Jump to next block if double block height */ } *pix++ = (uint8_t)*py++; /* Get and store a Y value as grayscale */ } } } /* Descale the MCU rectangular if needed */ if (JD_USE_SCALE && jd->scale) { unsigned int x, y, r, g, b, s, w, a; uint8_t *op; /* Get averaged RGB value of each square correcponds to a pixel */ s = jd->scale * 2; /* Number of shifts for averaging */ w = 1 << jd->scale; /* Width of square */ a = (mx - w) * (JD_FORMAT != 2 ? 3 : 1); /* Bytes to skip for next line in the square */ op = (uint8_t*)jd->workbuf; for (iy = 0; iy < my; iy += w) { for (ix = 0; ix < mx; ix += w) { pix = (uint8_t*)jd->workbuf + (iy * mx + ix) * (JD_FORMAT != 2 ? 3 : 1); r = g = b = 0; for (y = 0; y < w; y++) { /* Accumulate RGB value in the square */ for (x = 0; x < w; x++) { r += *pix++; /* Accumulate R or Y (monochrome output) */ if (JD_FORMAT != 2) { /* RGB output? */ g += *pix++; /* Accumulate G */ b += *pix++; /* Accumulate B */ } } pix += a; } /* Put the averaged pixel value */ *op++ = (uint8_t)(r >> s); /* Put R or Y (monochrome output) */ if (JD_FORMAT != 2) { /* RGB output? */ *op++ = (uint8_t)(g >> s); /* Put G */ *op++ = (uint8_t)(b >> s); /* Put B */ } } } } } else { /* For only 1/8 scaling (left-top pixel in each block are the DC value of the block) */ /* Build a 1/8 descaled RGB MCU from discrete comopnents */ pix = (uint8_t*)jd->workbuf; pc = jd->mcubuf + mx * my; cb = pc[0] - 128; /* Get Cb/Cr component and restore right level */ cr = pc[64] - 128; for (iy = 0; iy < my; iy += 8) { py = jd->mcubuf; if (iy == 8) py += 64 * 2; for (ix = 0; ix < mx; ix += 8) { yy = *py; /* Get Y component */ py += 64; if (JD_FORMAT != 2) { *pix++ = /*R*/ BYTECLIP(yy + ((int)(1.402 * CVACC) * cr / CVACC)); *pix++ = /*G*/ BYTECLIP(yy - ((int)(0.344 * CVACC) * cb + (int)(0.714 * CVACC) * cr) / CVACC); *pix++ = /*B*/ BYTECLIP(yy + ((int)(1.772 * CVACC) * cb / CVACC)); } else { *pix++ = yy; } } } } /* Squeeze up pixel table if a part of MCU is to be truncated */ mx >>= jd->scale; if (rx < mx) { /* Is the MCU spans rigit edge? */ uint8_t *s, *d; unsigned int x, y; s = d = (uint8_t*)jd->workbuf; for (y = 0; y < ry; y++) { for (x = 0; x < rx; x++) { /* Copy effective pixels */ *d++ = *s++; if (JD_FORMAT != 2) { *d++ = *s++; *d++ = *s++; } } s += (mx - rx) * (JD_FORMAT != 2 ? 3 : 1); /* Skip truncated pixels */ } } /* Convert RGB888 to RGB565 if needed */ if (JD_FORMAT == 1) { uint8_t *s = (uint8_t*)jd->workbuf; uint16_t w, *d = (uint16_t*)s; unsigned int n = rx * ry; do { w = (*s++ & 0xF8) << 8; /* RRRRR----------- */ w |= (*s++ & 0xFC) << 3; /* -----GGGGGG----- */ w |= *s++ >> 3; /* -----------BBBBB */ *d++ = w; } while (--n); } /* Output the rectangular */ return outfunc(jd, jd->workbuf, &rect) ? JDR_OK : JDR_INTR; } /*-----------------------------------------------------------------------*/ /* Analyze the JPEG image and Initialize decompressor object */ /*-----------------------------------------------------------------------*/ #define LDB_WORD(ptr) (uint16_t)(((uint16_t)*((uint8_t*)(ptr))<<8)|(uint16_t)*(uint8_t*)((ptr)+1)) JRESULT jd_prepare ( JDEC* jd, /* Blank decompressor object */ size_t (*infunc)(JDEC*, uint8_t*, size_t), /* JPEG strem input function */ void* pool, /* Working buffer for the decompression session */ size_t sz_pool, /* Size of working buffer */ void* dev /* I/O device identifier for the session */ ) { uint8_t *seg, b; uint16_t marker; unsigned int n, i, ofs; size_t len; JRESULT rc; memset(jd, 0, sizeof (JDEC)); /* Clear decompression object (this might be a problem if machine's null pointer is not all bits zero) */ jd->pool = pool; /* Work memroy */ jd->sz_pool = sz_pool; /* Size of given work memory */ jd->infunc = infunc; /* Stream input function */ jd->device = dev; /* I/O device identifier */ jd->inbuf = seg = alloc_pool(jd, JD_SZBUF); /* Allocate stream input buffer */ if (!seg) return JDR_MEM1; ofs = marker = 0; /* Find SOI marker */ do { if (jd->infunc(jd, seg, 1) != 1) return JDR_INP; /* Err: SOI was not detected */ ofs++; marker = marker << 8 | seg[0]; } while (marker != 0xFFD8); for (;;) { /* Parse JPEG segments */ /* Get a JPEG marker */ if (jd->infunc(jd, seg, 4) != 4) return JDR_INP; marker = LDB_WORD(seg); /* Marker */ len = LDB_WORD(seg + 2); /* Length field */ if (len <= 2 || (marker >> 8) != 0xFF) return JDR_FMT1; len -= 2; /* Segent content size */ ofs += 4 + len; /* Number of bytes loaded */ switch (marker & 0xFF) { case 0xC0: /* SOF0 (baseline JPEG) */ if (len > JD_SZBUF) return JDR_MEM2; if (jd->infunc(jd, seg, len) != len) return JDR_INP; /* Load segment data */ jd->width = LDB_WORD(&seg[3]); /* Image width in unit of pixel */ jd->height = LDB_WORD(&seg[1]); /* Image height in unit of pixel */ jd->ncomp = seg[5]; /* Number of color components */ if (jd->ncomp != 3 && jd->ncomp != 1) return JDR_FMT3; /* Err: Supports only Grayscale and Y/Cb/Cr */ /* Check each image component */ for (i = 0; i < jd->ncomp; i++) { b = seg[7 + 3 * i]; /* Get sampling factor */ if (i == 0) { /* Y component */ if (b != 0x11 && b != 0x22 && b != 0x21) { /* Check sampling factor */ return JDR_FMT3; /* Err: Supports only 4:4:4, 4:2:0 or 4:2:2 */ } jd->msx = b >> 4; jd->msy = b & 15; /* Size of MCU [blocks] */ } else { /* Cb/Cr component */ if (b != 0x11) return JDR_FMT3; /* Err: Sampling factor of Cb/Cr must be 1 */ } jd->qtid[i] = seg[8 + 3 * i]; /* Get dequantizer table ID for this component */ if (jd->qtid[i] > 3) return JDR_FMT3; /* Err: Invalid ID */ } break; case 0xDD: /* DRI - Define Restart Interval */ if (len > JD_SZBUF) return JDR_MEM2; if (jd->infunc(jd, seg, len) != len) return JDR_INP; /* Load segment data */ jd->nrst = LDB_WORD(seg); /* Get restart interval (MCUs) */ break; case 0xC4: /* DHT - Define Huffman Tables */ if (len > JD_SZBUF) return JDR_MEM2; if (jd->infunc(jd, seg, len) != len) return JDR_INP; /* Load segment data */ rc = create_huffman_tbl(jd, seg, len); /* Create huffman tables */ if (rc) return rc; break; case 0xDB: /* DQT - Define Quaitizer Tables */ if (len > JD_SZBUF) return JDR_MEM2; if (jd->infunc(jd, seg, len) != len) return JDR_INP; /* Load segment data */ rc = create_qt_tbl(jd, seg, len); /* Create de-quantizer tables */ if (rc) return rc; break; case 0xDA: /* SOS - Start of Scan */ if (len > JD_SZBUF) return JDR_MEM2; if (jd->infunc(jd, seg, len) != len) return JDR_INP; /* Load segment data */ if (!jd->width || !jd->height) return JDR_FMT1; /* Err: Invalid image size */ if (seg[0] != jd->ncomp) return JDR_FMT3; /* Err: Wrong color components */ /* Check if all tables corresponding to each components have been loaded */ for (i = 0; i < jd->ncomp; i++) { b = seg[2 + 2 * i]; /* Get huffman table ID */ if (b != 0x00 && b != 0x11) return JDR_FMT3; /* Err: Different table number for DC/AC element */ n = i ? 1 : 0; /* Component class */ if (!jd->huffbits[n][0] || !jd->huffbits[n][1]) { /* Check huffman table for this component */ return JDR_FMT1; /* Err: Nnot loaded */ } if (!jd->qttbl[jd->qtid[i]]) { /* Check dequantizer table for this component */ return JDR_FMT1; /* Err: Not loaded */ } } /* Allocate working buffer for MCU and pixel output */ n = jd->msy * jd->msx; /* Number of Y blocks in the MCU */ if (!n) return JDR_FMT1; /* Err: SOF0 has not been loaded */ len = n * 64 * 2 + 64; /* Allocate buffer for IDCT and RGB output */ if (len < 256) len = 256; /* but at least 256 byte is required for IDCT */ jd->workbuf = alloc_pool(jd, len); /* and it may occupy a part of following MCU working buffer for RGB output */ if (!jd->workbuf) return JDR_MEM1; /* Err: not enough memory */ jd->mcubuf = alloc_pool(jd, (n + 2) * 64 * sizeof (jd_yuv_t)); /* Allocate MCU working buffer */ if (!jd->mcubuf) return JDR_MEM1; /* Err: not enough memory */ /* Align stream read offset to JD_SZBUF */ if (ofs %= JD_SZBUF) { jd->dctr = jd->infunc(jd, seg + ofs, (size_t)(JD_SZBUF - ofs)); } jd->dptr = seg + ofs - (JD_FASTDECODE ? 0 : 1); return JDR_OK; /* Initialization succeeded. Ready to decompress the JPEG image. */ case 0xC1: /* SOF1 */ case 0xC2: /* SOF2 */ case 0xC3: /* SOF3 */ case 0xC5: /* SOF5 */ case 0xC6: /* SOF6 */ case 0xC7: /* SOF7 */ case 0xC9: /* SOF9 */ case 0xCA: /* SOF10 */ case 0xCB: /* SOF11 */ case 0xCD: /* SOF13 */ case 0xCE: /* SOF14 */ case 0xCF: /* SOF15 */ case 0xD9: /* EOI */ return JDR_FMT3; /* Unsuppoted JPEG standard (may be progressive JPEG) */ default: /* Unknown segment (comment, exif or etc..) */ /* Skip segment data (null pointer specifies to remove data from the stream) */ if (jd->infunc(jd, 0, len) != len) return JDR_INP; } } } /*-----------------------------------------------------------------------*/ /* Start to decompress the JPEG picture */ /*-----------------------------------------------------------------------*/ JRESULT jd_decomp ( JDEC* jd, /* Initialized decompression object */ int (*outfunc)(JDEC*, void*, JRECT*), /* RGB output function */ uint8_t scale /* Output de-scaling factor (0 to 3) */ ) { unsigned int x, y, mx, my; uint16_t rst, rsc; JRESULT rc; if (scale > (JD_USE_SCALE ? 3 : 0)) return JDR_PAR; jd->scale = scale; mx = jd->msx * 8; my = jd->msy * 8; /* Size of the MCU (pixel) */ jd->dcv[2] = jd->dcv[1] = jd->dcv[0] = 0; /* Initialize DC values */ rst = rsc = 0; rc = JDR_OK; for (y = 0; y < jd->height; y += my) { /* Vertical loop of MCUs */ for (x = 0; x < jd->width; x += mx) { /* Horizontal loop of MCUs */ if (jd->nrst && rst++ == jd->nrst) { /* Process restart interval if enabled */ rc = restart(jd, rsc++); if (rc != JDR_OK) return rc; rst = 1; } rc = mcu_load(jd); /* Load an MCU (decompress huffman coded stream, dequantize and apply IDCT) */ if (rc != JDR_OK) return rc; rc = mcu_output(jd, outfunc, x, y); /* Output the MCU (YCbCr to RGB, scaling and output) */ if (rc != JDR_OK) return rc; } } return rc; }
YifuLiu/AliOS-Things
components/py_engine/modules/display/esp32/tft/tjpgd.c
C
apache-2.0
43,093
/*----------------------------------------------------------------------------/ / TJpgDec - Tiny JPEG Decompressor R0.03 include file (C)ChaN, 2021 /----------------------------------------------------------------------------*/ #ifndef DEF_TJPGDEC #define DEF_TJPGDEC #ifdef __cplusplus extern "C" { #endif #include "tjpgdcnf.h" #include <string.h> #include <stdint.h> #if JD_FASTDECODE >= 1 typedef int16_t jd_yuv_t; #else typedef uint8_t jd_yuv_t; #endif /* Error code */ typedef enum { JDR_OK = 0, /* 0: Succeeded */ JDR_INTR, /* 1: Interrupted by output function */ JDR_INP, /* 2: Device error or wrong termination of input stream */ JDR_MEM1, /* 3: Insufficient memory pool for the image */ JDR_MEM2, /* 4: Insufficient stream input buffer */ JDR_PAR, /* 5: Parameter error */ JDR_FMT1, /* 6: Data format error (may be broken data) */ JDR_FMT2, /* 7: Right format but not supported */ JDR_FMT3 /* 8: Not supported JPEG standard */ } JRESULT; /* Rectangular region in the output image */ typedef struct { uint16_t left; /* Left end */ uint16_t right; /* Right end */ uint16_t top; /* Top end */ uint16_t bottom; /* Bottom end */ } JRECT; /* Decompressor object structure */ typedef struct JDEC JDEC; struct JDEC { size_t dctr; /* Number of bytes available in the input buffer */ uint8_t* dptr; /* Current data read ptr */ uint8_t* inbuf; /* Bit stream input buffer */ uint8_t dbit; /* Number of bits availavble in wreg or reading bit mask */ uint8_t scale; /* Output scaling ratio */ uint8_t msx, msy; /* MCU size in unit of block (width, height) */ uint8_t qtid[3]; /* Quantization table ID of each component, Y, Cb, Cr */ uint8_t ncomp; /* Number of color components 1:grayscale, 3:color */ int16_t dcv[3]; /* Previous DC element of each component */ uint16_t nrst; /* Restart inverval */ uint16_t width, height; /* Size of the input image (pixel) */ uint8_t* huffbits[2][2]; /* Huffman bit distribution tables [id][dcac] */ uint16_t* huffcode[2][2]; /* Huffman code word tables [id][dcac] */ uint8_t* huffdata[2][2]; /* Huffman decoded data tables [id][dcac] */ int32_t* qttbl[4]; /* Dequantizer tables [id] */ #if JD_FASTDECODE >= 1 uint32_t wreg; /* Working shift register */ uint8_t marker; /* Detected marker (0:None) */ #if JD_FASTDECODE == 2 uint8_t longofs[2][2]; /* Table offset of long code [id][dcac] */ uint16_t* hufflut_ac[2]; /* Fast huffman decode tables for AC short code [id] */ uint8_t* hufflut_dc[2]; /* Fast huffman decode tables for DC short code [id] */ #endif #endif void* workbuf; /* Working buffer for IDCT and RGB output */ jd_yuv_t* mcubuf; /* Working buffer for the MCU */ void* pool; /* Pointer to available memory pool */ size_t sz_pool; /* Size of momory pool (bytes available) */ size_t (*infunc)(JDEC*, uint8_t*, size_t); /* Pointer to jpeg stream input function */ void* device; /* Pointer to I/O device identifiler for the session */ }; /* TJpgDec API functions */ JRESULT jd_prepare (JDEC* jd, size_t (*infunc)(JDEC*,uint8_t*,size_t), void* pool, size_t sz_pool, void* dev); JRESULT jd_decomp (JDEC* jd, int (*outfunc)(JDEC*,void*,JRECT*), uint8_t scale); #ifdef __cplusplus } #endif #endif /* _TJPGDEC */
YifuLiu/AliOS-Things
components/py_engine/modules/display/esp32/tft/tjpgd.h
C
apache-2.0
3,264
/*----------------------------------------------*/ /* TJpgDec System Configurations R0.03 */ /*----------------------------------------------*/ #define JD_SZBUF 512 /* Specifies size of stream input buffer */ #define JD_FORMAT 0 /* Specifies output pixel format. / 0: RGB888 (24-bit/pix) / 1: RGB565 (16-bit/pix) / 2: Grayscale (8-bit/pix) */ #define JD_USE_SCALE 1 /* Switches output descaling feature. / 0: Disable / 1: Enable */ #define JD_TBLCLIP 1 /* Use table conversion for saturation arithmetic. A bit faster, but increases 1 KB of code size. / 0: Disable / 1: Enable */ #define JD_FASTDECODE 0 /* Optimization level / 0: Basic optimization. Suitable for 8/16-bit MCUs. / 1: + 32-bit barrel shifter. Suitable for 32-bit MCUs. / 2: + Table conversion for huffman decoding (wants 6 << HUFF_BIT bytes of RAM) */
YifuLiu/AliOS-Things
components/py_engine/modules/display/esp32/tft/tjpgdcnf.h
C
apache-2.0
845
/** * @file lv_conf.h * Configuration file for v8.1.0-release */ /* * Copy this file as `lv_conf.h` * 1. simply next to the `lvgl` folder * 2. or any other places and * - define `LV_CONF_INCLUDE_SIMPLE` * - add the path as include path */ /* clang-format off */ #if 1 /*Set it to "1" to enable content*/ #ifndef LV_CONF_H #define LV_CONF_H #include <stdint.h> #define LV_USE_FREETYPE 1 /*==================== COLOR SETTINGS *====================*/ /*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/ #ifndef LV_COLOR_DEPTH #define LV_COLOR_DEPTH 16 #endif /*Swap the 2 bytes of RGB565 color. Useful if the display has an 8-bit interface (e.g. SPI)*/ #ifndef LV_COLOR_16_SWAP #define LV_COLOR_16_SWAP 0 #endif /*Enable more complex drawing routines to manage screens transparency. *Can be used if the UI is above another layer, e.g. an OSD menu or video player. *Requires `LV_COLOR_DEPTH = 32` colors and the screen's `bg_opa` should be set to non LV_OPA_COVER value*/ #define LV_COLOR_SCREEN_TRANSP 0 /* Adjust color mix functions rounding. GPUs might calculate color mix (blending) differently. * 0: round down, 64: round up from x.75, 128: round up from half, 192: round up from x.25, 254: round up */ #define LV_COLOR_MIX_ROUND_OFS (LV_COLOR_DEPTH == 32 ? 0: 128) /*Images pixels with this color will not be drawn if they are chroma keyed)*/ #define LV_COLOR_CHROMA_KEY lv_color_hex(0x00ff00) /*pure green*/ /*========================= MEMORY SETTINGS *=========================*/ /*1: use custom malloc/free, 0: use the built-in `lv_mem_alloc()` and `lv_mem_free()`*/ #define LV_MEM_CUSTOM 1 #if LV_MEM_CUSTOM == 0 /*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/ # define LV_MEM_SIZE (32U * 1024U) /*[bytes]*/ /*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/ # define LV_MEM_ADR 0 /*0: unused*/ /*Instead of an address give a memory allocator that will be called to get a memory pool for LVGL. E.g. my_malloc*/ #if LV_MEM_ADR == 0 //#define LV_MEM_POOL_INCLUDE your_alloc_library /* Uncomment if using an external allocator*/ //#define LV_MEM_POOL_ALLOC your_alloc /* Uncomment if using an external allocator*/ #endif #else /*LV_MEM_CUSTOM*/ # define LV_MEM_CUSTOM_INCLUDE "include/lv_mp_mem_custom_include.h" /*Header for the dynamic memory function*/ # define LV_MEM_CUSTOM_ALLOC m_malloc /*Wrapper to malloc*/ # define LV_MEM_CUSTOM_FREE m_free /*Wrapper to free*/ # define LV_MEM_CUSTOM_REALLOC m_realloc #endif /*LV_MEM_CUSTOM*/ /*Use the standard `memcpy` and `memset` instead of LVGL's own functions. (Might or might not be faster).*/ #define LV_MEMCPY_MEMSET_STD 0 /*==================== HAL SETTINGS *====================*/ /*Default display refresh period. LVG will redraw changed areas with this period time*/ #define LV_DISP_DEF_REFR_PERIOD 20 /*[ms]*/ /*Input device read period in milliseconds*/ #define LV_INDEV_DEF_READ_PERIOD 30 /*[ms]*/ /*Use a custom tick source that tells the elapsed time in milliseconds. *It removes the need to manually update the tick with `lv_tick_inc()`)*/ #define LV_TICK_CUSTOM 0 #if LV_TICK_CUSTOM #define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the system time function*/ #define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current system time in ms*/ #endif /*LV_TICK_CUSTOM*/ /*Default Dot Per Inch. Used to initialize default sizes such as widgets sized, style paddings. *(Not so important, you can adjust it to modify default sizes and spaces)*/ #define LV_DPI_DEF 130 /*[px/inch]*/ /*======================= * FEATURE CONFIGURATION *=======================*/ /*------------- * Drawing *-----------*/ /*Enable complex draw engine. *Required to draw shadow, gradient, rounded corners, circles, arc, skew lines, image transformations or any masks*/ #define LV_DRAW_COMPLEX 1 #if LV_DRAW_COMPLEX != 0 /*Allow buffering some shadow calculation. *LV_SHADOW_CACHE_SIZE is the max. shadow size to buffer, where shadow size is `shadow_width + radius` *Caching has LV_SHADOW_CACHE_SIZE^2 RAM cost*/ #define LV_SHADOW_CACHE_SIZE 0 /* Set number of maximally cached circle data. * The circumference of 1/4 circle are saved for anti-aliasing * radius * 4 bytes are used per circle (the most often used radiuses are saved) * 0: to disable caching */ #define LV_CIRCLE_CACHE_SIZE 4 #endif /*LV_DRAW_COMPLEX*/ /*Default image cache size. Image caching keeps the images opened. *If only the built-in image formats are used there is no real advantage of caching. (I.e. if no new image decoder is added) *With complex image decoders (e.g. PNG or JPG) caching can save the continuous open/decode of images. *However the opened images might consume additional RAM. *0: to disable caching*/ #define LV_IMG_CACHE_DEF_SIZE 64 /*Maximum buffer size to allocate for rotation. Only used if software rotation is enabled in the display driver.*/ #define LV_DISP_ROT_MAX_BUF (10*1024) /*------------- * GPU *-----------*/ /*Use STM32's DMA2D (aka Chrom Art) GPU*/ #define LV_USE_GPU_STM32_DMA2D 0 #if LV_USE_GPU_STM32_DMA2D /*Must be defined to include path of CMSIS header of target processor e.g. "stm32f769xx.h" or "stm32f429xx.h"*/ #define LV_GPU_DMA2D_CMSIS_INCLUDE #endif /*Use NXP's PXP GPU iMX RTxxx platforms*/ #define LV_USE_GPU_NXP_PXP 0 #if LV_USE_GPU_NXP_PXP /*1: Add default bare metal and FreeRTOS interrupt handling routines for PXP (lv_gpu_nxp_pxp_osa.c) * and call lv_gpu_nxp_pxp_init() automatically during lv_init(). Note that symbol SDK_OS_FREE_RTOS * has to be defined in order to use FreeRTOS OSA, otherwise bare-metal implementation is selected. *0: lv_gpu_nxp_pxp_init() has to be called manually before lv_init() */ #define LV_USE_GPU_NXP_PXP_AUTO_INIT 0 #endif /*Use NXP's VG-Lite GPU iMX RTxxx platforms*/ #define LV_USE_GPU_NXP_VG_LITE 0 /*Use SDL renderer API*/ #ifndef LV_USE_GPU_SDL # ifdef CONFIG_LV_USE_GPU_SDL # define LV_USE_GPU_SDL CONFIG_LV_USE_GPU_SDL # else # define LV_USE_GPU_SDL 0 # endif #endif #if LV_USE_GPU_SDL # define LV_USE_EXTERNAL_RENDERER 1 # ifndef LV_GPU_SDL_INCLUDE # define LV_GPU_SDL_INCLUDE_PATH <SDL2/SDL.h> # endif #endif #ifndef LV_USE_EXTERNAL_RENDERER # define LV_USE_EXTERNAL_RENDERER 0 #endif /*------------- * Logging *-----------*/ /*Enable the log module*/ #define LV_USE_LOG 1 #if LV_USE_LOG /*How important log should be added: *LV_LOG_LEVEL_TRACE A lot of logs to give detailed information *LV_LOG_LEVEL_INFO Log important events *LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't cause a problem *LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail *LV_LOG_LEVEL_USER Only logs added by the user *LV_LOG_LEVEL_NONE Do not log anything*/ # define LV_LOG_LEVEL LV_LOG_LEVEL_WARN /*1: Print the log with 'printf'; *0: User need to register a callback with `lv_log_register_print_cb()`*/ # define LV_LOG_PRINTF 0 /*Enable/disable LV_LOG_TRACE in modules that produces a huge number of logs*/ # define LV_LOG_TRACE_MEM 1 # define LV_LOG_TRACE_TIMER 1 # define LV_LOG_TRACE_INDEV 1 # define LV_LOG_TRACE_DISP_REFR 1 # define LV_LOG_TRACE_EVENT 1 # define LV_LOG_TRACE_OBJ_CREATE 1 # define LV_LOG_TRACE_LAYOUT 1 # define LV_LOG_TRACE_ANIM 1 #endif /*LV_USE_LOG*/ /*------------- * Asserts *-----------*/ /*Enable asserts if an operation is failed or an invalid data is found. *If LV_USE_LOG is enabled an error message will be printed on failure*/ #define LV_USE_ASSERT_NULL 1 /*Check if the parameter is NULL. (Very fast, recommended)*/ #define LV_USE_ASSERT_MALLOC 1 /*Checks is the memory is successfully allocated or no. (Very fast, recommended)*/ #define LV_USE_ASSERT_STYLE 0 /*Check if the styles are properly initialized. (Very fast, recommended)*/ #define LV_USE_ASSERT_MEM_INTEGRITY 0 /*Check the integrity of `lv_mem` after critical operations. (Slow)*/ #define LV_USE_ASSERT_OBJ 0 /*Check the object's type and existence (e.g. not deleted). (Slow)*/ /*Add a custom handler when assert happens e.g. to restart the MCU*/ #define LV_ASSERT_HANDLER_INCLUDE <stdint.h> #define LV_ASSERT_HANDLER while(1); /*Halt by default*/ /*------------- * Others *-----------*/ /*1: Show CPU usage and FPS count in the right bottom corner*/ #define LV_USE_PERF_MONITOR 0 /*1: Show the used memory and the memory fragmentation in the left bottom corner * Requires LV_MEM_CUSTOM = 0*/ #define LV_USE_MEM_MONITOR 0 /*1: Draw random colored rectangles over the redrawn areas*/ #define LV_USE_REFR_DEBUG 0 /*Change the built in (v)snprintf functions*/ #define LV_SPRINTF_CUSTOM 1 #if LV_SPRINTF_CUSTOM # define LV_SPRINTF_INCLUDE <stdio.h> # define lv_snprintf snprintf # define lv_vsnprintf vsnprintf #else /*LV_SPRINTF_CUSTOM*/ # define LV_SPRINTF_USE_FLOAT 0 #endif /*LV_SPRINTF_CUSTOM*/ #define LV_USE_USER_DATA 1 /*Garbage Collector settings *Used if lvgl is bound to higher level language and the memory is managed by that language*/ #define LV_ENABLE_GC 1 /* Enable GC for Micropython */ #if LV_ENABLE_GC != 0 # define LV_GC_INCLUDE "py/mpstate.h" # define LV_MEM_CUSTOM_GET_SIZE gc_nbytes /*Wrapper to lv_mem_get_size*/ # define LV_GC_ROOT(x) MP_STATE_PORT(x) #endif /*LV_ENABLE_GC*/ /*1: Enable API to take snapshot for object*/ #define LV_USE_SNAPSHOT 1 /*===================== * COMPILER SETTINGS *====================*/ /*For big endian systems set to 1*/ #define LV_BIG_ENDIAN_SYSTEM 0 /*Define a custom attribute to `lv_tick_inc` function*/ #define LV_ATTRIBUTE_TICK_INC /*Define a custom attribute to `lv_timer_handler` function*/ #define LV_ATTRIBUTE_TIMER_HANDLER /*Define a custom attribute to `lv_disp_flush_ready` function*/ #define LV_ATTRIBUTE_FLUSH_READY /*Required alignment size for buffers*/ #define LV_ATTRIBUTE_MEM_ALIGN_SIZE /*Will be added where memories needs to be aligned (with -Os data might not be aligned to boundary by default). * E.g. __attribute__((aligned(4)))*/ #define LV_ATTRIBUTE_MEM_ALIGN /*Attribute to mark large constant arrays for example font's bitmaps*/ #define LV_ATTRIBUTE_LARGE_CONST /*Complier prefix for a big array declaration in RAM*/ #define LV_ATTRIBUTE_LARGE_RAM_ARRAY /*Place performance critical functions into a faster memory (e.g RAM)*/ #define LV_ATTRIBUTE_FAST_MEM /*Prefix variables that are used in GPU accelerated operations, often these need to be placed in RAM sections that are DMA accessible*/ #define LV_ATTRIBUTE_DMA /*Export integer constant to binding. This macro is used with constants in the form of LV_<CONST> that *should also appear on LVGL binding API such as Micropython.*/ #define LV_EXPORT_CONST_INT(int_value) enum {ENUM_##int_value = int_value} /*Extend the default -32k..32k coordinate range to -4M..4M by using int32_t for coordinates instead of int16_t*/ #define LV_USE_LARGE_COORD 0 /*================== * FONT USAGE *===================*/ /*Montserrat fonts with ASCII range and some symbols using bpp = 4 *https://fonts.google.com/specimen/Montserrat*/ #define LV_FONT_MONTSERRAT_8 1 #define LV_FONT_MONTSERRAT_10 1 #define LV_FONT_MONTSERRAT_12 1 #define LV_FONT_MONTSERRAT_14 1 #define LV_FONT_MONTSERRAT_16 1 #define LV_FONT_MONTSERRAT_18 1 #define LV_FONT_MONTSERRAT_20 1 #define LV_FONT_MONTSERRAT_22 1 #define LV_FONT_MONTSERRAT_24 1 #define LV_FONT_MONTSERRAT_26 1 #define LV_FONT_MONTSERRAT_28 1 #define LV_FONT_MONTSERRAT_30 1 #define LV_FONT_MONTSERRAT_32 1 #define LV_FONT_MONTSERRAT_34 1 #define LV_FONT_MONTSERRAT_36 1 #define LV_FONT_MONTSERRAT_38 1 #define LV_FONT_MONTSERRAT_40 1 #define LV_FONT_MONTSERRAT_42 1 #define LV_FONT_MONTSERRAT_44 1 #define LV_FONT_MONTSERRAT_46 1 #define LV_FONT_MONTSERRAT_48 1 /*Demonstrate special features*/ #define LV_FONT_MONTSERRAT_12_SUBPX 0 #define LV_FONT_MONTSERRAT_28_COMPRESSED 0 /*bpp = 3*/ #define LV_FONT_DEJAVU_16_PERSIAN_HEBREW 1 /*Hebrew, Arabic, Perisan letters and all their forms*/ #define LV_FONT_SIMSUN_16_CJK 0 /*1000 most common CJK radicals*/ /*Pixel perfect monospace fonts*/ #define LV_FONT_UNSCII_8 0 #define LV_FONT_UNSCII_16 0 /*Optionally declare custom fonts here. *You can use these fonts as default font too and they will be available globally. *E.g. #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) LV_FONT_DECLARE(my_font_2)*/ #define LV_FONT_CUSTOM_DECLARE /*Always set a default font*/ #define LV_FONT_DEFAULT &lv_font_montserrat_14 /*Enable handling large font and/or fonts with a lot of characters. *The limit depends on the font size, font face and bpp. *Compiler error will be triggered if a font needs it.*/ #define LV_FONT_FMT_TXT_LARGE 0 /*Enables/disables support for compressed fonts.*/ #define LV_USE_FONT_COMPRESSED 0 /*Enable subpixel rendering*/ #define LV_USE_FONT_SUBPX 0 #if LV_USE_FONT_SUBPX /*Set the pixel order of the display. Physical order of RGB channels. Doesn't matter with "normal" fonts.*/ #define LV_FONT_SUBPX_BGR 0 /*0: RGB; 1:BGR order*/ #endif /*================= * TEXT SETTINGS *=================*/ /** * Select a character encoding for strings. * Your IDE or editor should have the same character encoding * - LV_TXT_ENC_UTF8 * - LV_TXT_ENC_ASCII */ #define LV_TXT_ENC LV_TXT_ENC_UTF8 /*Can break (wrap) texts on these chars*/ #define LV_TXT_BREAK_CHARS " ,.;:-_" /*If a word is at least this long, will break wherever "prettiest" *To disable, set to a value <= 0*/ #define LV_TXT_LINE_BREAK_LONG_LEN 0 /*Minimum number of characters in a long word to put on a line before a break. *Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/ #define LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN 3 /*Minimum number of characters in a long word to put on a line after a break. *Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/ #define LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN 3 /*The control character to use for signalling text recoloring.*/ #define LV_TXT_COLOR_CMD "#" /*Support bidirectional texts. Allows mixing Left-to-Right and Right-to-Left texts. *The direction will be processed according to the Unicode Bidirectional Algorithm: *https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/ #define LV_USE_BIDI 1 #if LV_USE_BIDI /*Set the default direction. Supported values: *`LV_BASE_DIR_LTR` Left-to-Right *`LV_BASE_DIR_RTL` Right-to-Left *`LV_BASE_DIR_AUTO` detect texts base direction*/ #define LV_BIDI_BASE_DIR_DEF LV_BASE_DIR_AUTO #endif /*Enable Arabic/Persian processing *In these languages characters should be replaced with an other form based on their position in the text*/ #define LV_USE_ARABIC_PERSIAN_CHARS 1 /*================== * WIDGET USAGE *================*/ /*Documentation of the widgets: https://docs.lvgl.io/latest/en/html/widgets/index.html*/ #define LV_USE_ARC 1 #define LV_USE_ANIMIMG 1 #define LV_USE_BAR 1 #define LV_USE_BTN 1 #define LV_USE_BTNMATRIX 1 #define LV_USE_CANVAS 1 #define LV_USE_CHECKBOX 1 #define LV_USE_DROPDOWN 1 /*Requires: lv_label*/ #define LV_USE_IMG 1 /*Requires: lv_label*/ #define LV_USE_LABEL 1 #if LV_USE_LABEL # define LV_LABEL_TEXT_SELECTION 1 /*Enable selecting text of the label*/ # define LV_LABEL_LONG_TXT_HINT 1 /*Store some extra info in labels to speed up drawing of very long texts*/ #endif #define LV_USE_LINE 1 #define LV_USE_ROLLER 1 /*Requires: lv_label*/ #if LV_USE_ROLLER # define LV_ROLLER_INF_PAGES 7 /*Number of extra "pages" when the roller is infinite*/ #endif #define LV_USE_SLIDER 1 /*Requires: lv_bar*/ #define LV_USE_SWITCH 1 #define LV_USE_TEXTAREA 1 /*Requires: lv_label*/ #if LV_USE_TEXTAREA != 0 # define LV_TEXTAREA_DEF_PWD_SHOW_TIME 1500 /*ms*/ #endif #define LV_USE_TABLE 1 /*================== * EXTRA COMPONENTS *==================*/ /*----------- * Widgets *----------*/ #define LV_USE_CALENDAR 1 #if LV_USE_CALENDAR # define LV_CALENDAR_WEEK_STARTS_MONDAY 0 # if LV_CALENDAR_WEEK_STARTS_MONDAY # define LV_CALENDAR_DEFAULT_DAY_NAMES {"Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"} # else # define LV_CALENDAR_DEFAULT_DAY_NAMES {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"} # endif # define LV_CALENDAR_DEFAULT_MONTH_NAMES {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"} # define LV_USE_CALENDAR_HEADER_ARROW 1 # define LV_USE_CALENDAR_HEADER_DROPDOWN 1 #endif /*LV_USE_CALENDAR*/ #define LV_USE_CHART 1 #define LV_USE_COLORWHEEL 1 #define LV_USE_IMGBTN 1 #define LV_USE_KEYBOARD 1 #define LV_USE_LED 1 #define LV_USE_LIST 1 #define LV_USE_METER 1 #define LV_USE_MSGBOX 1 #define LV_USE_SPINBOX 1 #define LV_USE_SPINNER 1 #define LV_USE_TABVIEW 1 #define LV_USE_TILEVIEW 1 #define LV_USE_WIN 1 #define LV_USE_SPAN 1 #if LV_USE_SPAN /*A line text can contain maximum num of span descriptor */ # define LV_SPAN_SNIPPET_STACK_SIZE 64 #endif /*----------- * Themes *----------*/ /*A simple, impressive and very complete theme*/ #define LV_USE_THEME_DEFAULT 1 #if LV_USE_THEME_DEFAULT /*0: Light mode; 1: Dark mode*/ # define LV_THEME_DEFAULT_DARK 0 /*1: Enable grow on press*/ # define LV_THEME_DEFAULT_GROW 1 /*Default transition time in [ms]*/ # define LV_THEME_DEFAULT_TRANSITON_TIME 80 #endif /*LV_USE_THEME_DEFAULT*/ /*A very simple theme that is a good starting point for a custom theme*/ #define LV_USE_THEME_BASIC 1 /*A theme designed for monochrome displays*/ #define LV_USE_THEME_MONO 1 /*----------- * Layouts *----------*/ /*A layout similar to Flexbox in CSS.*/ #define LV_USE_FLEX 1 /*A layout similar to Grid in CSS.*/ #define LV_USE_GRID 1 #define LV_USE_FS_POSIX 'S' #define LV_USE_SJPG 1 #define LV_USE_PNG 1 /*================== * EXAMPLES *==================*/ /*Enable the examples to be built with the library*/ #define LV_BUILD_EXAMPLES 1 /*--END OF LV_CONF_H--*/ #endif /*LV_CONF_H*/ #endif /*End of "Content enable"*/
YifuLiu/AliOS-Things
components/py_engine/modules/display/haas/lv_conf.h
C
apache-2.0
18,689
/* LVGL Example project * * Basic project to test LVGL on ESP32 based projects. * * This example code is in the Public Domain (or CC0 licensed, at your option.) * * Unless required by applicable law or agreed to in writing, this * software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. */ #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <aos/kernel.h> #include "py/objstr.h" #include "py/runtime.h" #include "py/stackctrl.h" #if MICROPY_PY_THREAD #include "py/mpthread.h" #endif /* Littlevgl specific */ #ifdef LV_LVGL_H_INCLUDE_SIMPLE #include "lvgl.h" #else #include "lvgl/lvgl.h" #endif #include "moddisplay.h" #include "ft6336.h" #define LV_TICK_PERIOD_MS 1 #define DISP_BUF_SIZE (240 * 320) static bool lvgl_display_init = false; static void lv_tick_task(void *arg); static void guiTask(void *pvParameter); static void drawDisplay(); aos_mutex_t mutex_handle; aos_timer_t timer_tick; static void display_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map); static void touch_read(lv_indev_drv_t *drv, lv_indev_data_t *data); extern void st7789_frame_draw(uint8_t *frame); extern void st7789_rect_draw(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color); extern void st7789_local_refresh(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint8_t *frame); extern uint8_t st7789_init(void); typedef void (*mp_task_entry_t)(void *arg); struct mp_task_struct { mp_task_entry_t entry; size_t stack_size; void *arg; mp_obj_dict_t *dict_locals; mp_obj_dict_t *dict_globals; }; typedef struct _display_lvgl_obj_t { mp_obj_base_t base; } display_lvgl_obj_t; const mp_obj_type_t display_lvgl_type; void mp_thread_entry_c(void *arg) { struct mp_task_struct *task_struct = (struct mp_task_struct *)arg; mp_state_thread_t ts; mp_thread_set_state(&ts); mp_task_entry_t entry = task_struct->entry; void *task_param = task_struct->arg; mp_stack_set_top(&ts + 1); // need to include ts in root-pointer scan mp_stack_set_limit(task_struct->stack_size); #if MICROPY_ENABLE_PYSTACK // TODO threading and pystack is not fully supported, for now just make a small stack mp_obj_t mini_pystack[128]; mp_pystack_init(mini_pystack, &mini_pystack[128]); #endif ts.mp_pending_exception = MP_OBJ_NULL; // set locals and globals from the calling context mp_locals_set(task_struct->dict_locals); mp_globals_set(task_struct->dict_globals); // signal that we are set up and running entry(task_param); } int mp_thread_create_c(mp_task_entry_t pxTaskCode, const char *const pcName, const uint32_t usStackDepth, void *const pvParameters, const uint32_t uxPriority) { struct mp_task_struct *task_struct; printf("entern mp_thread_create_c\r\n"); task_struct = (struct mp_task_struct *)malloc(sizeof(struct mp_task_struct)); memset(task_struct, 0, sizeof(struct mp_task_struct)); task_struct->entry = pxTaskCode; task_struct->arg = pvParameters; task_struct->dict_locals = mp_locals_get(); task_struct->dict_globals = mp_globals_get(); task_struct->stack_size = usStackDepth - 1024; mp_thread_create(mp_thread_entry_c, task_struct, &usStackDepth); mp_thread_start(); printf("out mp_thread_create_c\r\n"); return 0; } void start_display() { printf("start_display\n"); mp_thread_create_c(guiTask, "gui", 4 * 1024, NULL, AOS_DEFAULT_APP_PRI); printf("out_display\n"); } void driver_init() { FT6336_init();//touch driver init st7789_init(); //driver init start_display(); } STATIC mp_obj_t mp_lv_task_handler(mp_obj_t arg) { lv_task_handler(); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_lv_task_handler_obj, mp_lv_task_handler); static void guiTask(void *pvParameter) { (void)pvParameter; printf("gui task entern\r\n"); aos_status_t status; printf("mutex create\n"); status = aos_mutex_create(&mutex_handle, 0); if (status != 0) { printf("[%s]create mutex error\n", __FUNCTION__); return ; } printf("timer create\n"); //aos_status_t status; /* Create and start a periodic timer interrupt to call lv_tick_inc */ status = aos_timer_create(&timer_tick, lv_tick_task, NULL, (LV_TICK_PERIOD_MS), AOS_TIMER_REPEAT); if (status != 0) { printf("[%s]create timer error\n", __FUNCTION__); return; } aos_timer_start(&timer_tick); while (1) { /* Delay 1 tick (assumes FreeRTOS tick is 10ms */ aos_msleep(30); /* Try to take the semaphore, call lvgl related function on success */ status = aos_mutex_lock(&mutex_handle, AOS_WAIT_FOREVER); if (status == 0) { callback_to_python_LoBo((mp_obj_t)&mp_lv_task_handler_obj, mp_const_none, NULL); aos_mutex_unlock(&mutex_handle); } } vTaskDelete(NULL); aos_mutex_free(&mutex_handle); } /********************** * APPLICATION MAIN **********************/ STATIC mp_obj_t app_monkey_test(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { lv_monkey_init(); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mp_monkey_test, 0, app_monkey_test); static lv_disp_draw_buf_t disp_buf; static lv_disp_drv_t disp_drv; static lv_indev_drv_t indev_drv; static void drawDisplay() { // lv_color_t *buf1 = heap_caps_malloc(DISP_BUF_SIZE * sizeof(lv_color_t), MALLOC_CAP_DMA); lv_color_t *buf1 = (lv_color_t *)malloc(DISP_BUF_SIZE * sizeof(lv_color_t)); assert(buf1 != NULL); // lv_color_t *buf2 = heap_caps_malloc(DISP_BUF_SIZE * sizeof(lv_color_t), MALLOC_CAP_DMA); lv_color_t *buf2 = (lv_color_t *)malloc(DISP_BUF_SIZE * sizeof(lv_color_t)); assert(buf2 != NULL); uint32_t size_in_px = DISP_BUF_SIZE; lv_disp_draw_buf_init(&disp_buf, buf1, buf2, size_in_px); lv_disp_drv_init(&disp_drv); disp_drv.hor_res = 320; disp_drv.ver_res = 240; disp_drv.flush_cb = display_flush; disp_drv.draw_buf = &disp_buf; lv_disp_drv_register(&disp_drv); printf("register touch driver\r\n"); lv_indev_drv_init(&indev_drv); indev_drv.read_cb = touch_read; indev_drv.type = LV_INDEV_TYPE_POINTER; lv_indev_drv_register(&indev_drv); } static void lv_tick_task(void *arg) { (void)arg; lv_tick_inc(LV_TICK_PERIOD_MS); } static void display_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map) { printf("display_flush area: %d %d %d %d ;%p\n", area->x1, area->y1, area->x2, area->y2, color_map); //st7789_frame_draw((uint8_t*)color_map); uint16_t x = area->x1; uint16_t y = area->y1; uint16_t w = area->x2 - area->x1 + 1; uint16_t h = area->y2 - area->y1 + 1; //printf("display_flush area: %d %d %d %d ;%p\n", x, y, w, h, (uint16_t*)color_map); //st7789_rect_draw(x, y, w, h, (uint16_t*)color_map); //st7789_frame_draw((uint8_t*)color_map); st7789_local_refresh(area->x1, area->y1, area->x2, area->y2,(uint8_t*)color_map); lv_disp_flush_ready(drv); } DEFINE_PTR_OBJ(display_flush); static void touch_read(lv_indev_drv_t *drv, lv_indev_data_t *data) { //printf("touch_read\n"); //touch_driver_read(drv, data); if (data == NULL) return; TouchPointEvent event; event.status = -1; event.x = 0; event.y = 0; event = FT6336_read_point(); //data->continue_reading = false; if (event.status == 0) { data->point.x = event.x; data->point.y = event.y; data->state = LV_INDEV_STATE_REL; } else if (event.status == 1) { data->point.x = event.x; data->point.y = event.y; data->state = LV_INDEV_STATE_PR; } //printf("touch_read x = %d;y = %d;state= %d;\n", data->point.x,data->point.y,data->state); } DEFINE_PTR_OBJ(touch_read); STATIC mp_obj_t is_initialized(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { bool _res = (bool)lvgl_display_init; printf("check init = %d;_res = %d;\r\n", lvgl_display_init, _res); return _res ? mp_const_true : mp_const_false; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mp_is_initialized_obj, 0, is_initialized); STATIC mp_obj_t app_init(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { printf("app_init\r\n"); lvgl_display_init = true; driver_init(); drawDisplay(); return mp_obj_new_int(0); } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mp_display_init_obj, 0, app_init); STATIC mp_obj_t app_draw(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { printf("app_draw\r\n"); lv_init(); drawDisplay(); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mp_display_draw_obj, 0, app_draw); STATIC const mp_rom_map_elem_t display_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_lvgl_display) }, { MP_ROM_QSTR(MP_QSTR_is_initialized), MP_ROM_PTR(&mp_is_initialized_obj) }, { MP_ROM_QSTR(MP_QSTR_init), MP_ROM_PTR(&mp_display_init_obj) }, { MP_ROM_QSTR(MP_QSTR_flush), MP_ROM_PTR(&PTR_OBJ(display_flush)) }, { MP_ROM_QSTR(MP_QSTR_touch_read), MP_ROM_PTR(&PTR_OBJ(touch_read)) }, // for test start { MP_ROM_QSTR(MP_QSTR_draw), MP_ROM_PTR(&mp_display_draw_obj) }, { MP_ROM_QSTR(MP_QSTR_monkey_test), MP_ROM_PTR(&mp_monkey_test) }, // for test end }; STATIC MP_DEFINE_CONST_DICT(mp_module_display_globals, display_globals_table); const mp_obj_module_t mp_module_lvgl_display = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t*)&mp_module_display_globals }; MP_REGISTER_MODULE(MP_QSTR_lvgl_display, mp_module_lvgl_display, MICROPY_PY_LVGL);
YifuLiu/AliOS-Things
components/py_engine/modules/display/haas/moddisplay.c
C
apache-2.0
9,808
#ifndef __LVMP_DRV_COMMON_H #define __LVMP_DRV_COMMON_H #include "py/obj.h" #include "py/runtime.h" #include "py/binary.h" ////////////////////////////////////////////////////////////////////////////// // A read-only buffer that contains a C pointer // Used to communicate function pointers to lvgl Micropython bindings // typedef struct mp_ptr_t { mp_obj_base_t base; void *ptr; } mp_ptr_t; STATIC mp_int_t mp_ptr_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) { mp_ptr_t *self = MP_OBJ_TO_PTR(self_in); if (flags & MP_BUFFER_WRITE) { // read-only ptr return 1; } bufinfo->buf = &self->ptr; bufinfo->len = sizeof(self->ptr); bufinfo->typecode = BYTEARRAY_TYPECODE; return 0; } #define PTR_OBJ(ptr_global) ptr_global ## _obj #define DEFINE_PTR_OBJ_TYPE(ptr_obj_type, ptr_type_qstr)\ STATIC const mp_obj_type_t ptr_obj_type = {\ { &mp_type_type },\ .name = ptr_type_qstr,\ .buffer_p = { .get_buffer = mp_ptr_get_buffer }\ } #define DEFINE_PTR_OBJ(ptr_global)\ DEFINE_PTR_OBJ_TYPE(ptr_global ## _type, MP_QSTR_ ## ptr_global);\ STATIC const mp_ptr_t PTR_OBJ(ptr_global) = {\ { &ptr_global ## _type },\ &ptr_global\ } #define NEW_PTR_OBJ(name, value)\ ({\ DEFINE_PTR_OBJ_TYPE(ptr_obj_type, MP_QSTR_ ## name);\ mp_ptr_t *self = m_new_obj(mp_ptr_t);\ self->base.type = &ptr_obj_type;\ self->ptr = value;\ MP_OBJ_FROM_PTR(self);\ }) #endif // __LVMP_DRV_COMMON_H
YifuLiu/AliOS-Things
components/py_engine/modules/display/moddisplay.h
C
apache-2.0
1,486
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "aos_hal_adc.h" #include "board_mgr.h" #include "py/builtin.h" #include "py/mperrno.h" #include "py/obj.h" #include "py/runtime.h" #include "ulog/ulog.h" #define LOG_TAG "DRIVER_ADC" extern const mp_obj_type_t driver_adc_type; // this is the actual C-structure for our new object typedef struct { // base represents some basic information, like type mp_obj_base_t Base; // a member created by us char *ModuleName; item_handle_t adc_handle; } mp_adc_obj_t; void adc_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { mp_adc_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_printf(print, "ModuleName(%s)", self->ModuleName); } STATIC mp_obj_t adc_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_adc_obj_t *driver_obj = m_new_obj(mp_adc_obj_t); if (!driver_obj) { mp_raise_OSError(MP_ENOMEM); } memset(driver_obj, 0, sizeof(mp_adc_obj_t)); driver_obj->Base.type = &driver_adc_type; driver_obj->ModuleName = "adc"; driver_obj->adc_handle.handle = NULL; return MP_OBJ_FROM_PTR(driver_obj); } STATIC mp_obj_t adc_open(size_t n_args, const mp_obj_t *args) { int ret = -1; if (n_args < 2) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return MP_OBJ_NEW_SMALL_INT (-MP_E2BIG); } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_adc_obj_t *driver_obj = (mp_adc_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return MP_OBJ_NEW_SMALL_INT (-MP_EINVAL); } char *id = (char *)mp_obj_str_get_str(args[1]); if (id == NULL) { LOGE(LOG_TAG, "%s:illegal par id =%s;\n", __func__, id); return MP_OBJ_NEW_SMALL_INT (-MP_EINVAL); } ret = py_board_mgr_init(); if (ret != 0) { LOGE(LOG_TAG, "%s:py_board_mgr_init failed\n", __func__); return MP_OBJ_NEW_SMALL_INT (-MP_ENOENT); } ret = py_board_attach_item(MODULE_ADC, id, &(driver_obj->adc_handle)); if (ret != 0) { LOGE(LOG_TAG, "%s: py_board_attach_item failed ret = %d;\n", __func__, ret); goto out; } adc_dev_t *adc_device = py_board_get_node_by_handle(MODULE_ADC, &(driver_obj->adc_handle)); if (NULL == adc_device) { LOGE(LOG_TAG, "%s: py_board_get_node_by_handle failed;\n", __func__); goto out; } ret = aos_hal_adc_init(adc_device); out: if (0 != ret) { LOGE(LOG_TAG, "%s: adc open failed ret = %d;\n", __func__, ret); py_board_disattach_item(MODULE_ADC, &(driver_obj->adc_handle)); } return MP_OBJ_NEW_SMALL_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(adc_open_obj, 2, adc_open); STATIC mp_obj_t adc_close(size_t n_args, const mp_obj_t *args) { int ret = -1; adc_dev_t *adc_device = NULL; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return MP_OBJ_NEW_SMALL_INT (-MP_E2BIG); } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_adc_obj_t *driver_obj = (mp_adc_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return MP_OBJ_NEW_SMALL_INT (-MP_EINVAL); } adc_device = py_board_get_node_by_handle(MODULE_ADC, &(driver_obj->adc_handle)); if (NULL == adc_device) { LOGE(LOG_TAG, "%s: py_board_get_node_by_handle failed;\n", __func__); return MP_OBJ_NEW_SMALL_INT (-MP_ENODEV); } ret = aos_hal_adc_finalize(adc_device); py_board_disattach_item(MODULE_ADC, &(driver_obj->adc_handle)); return MP_OBJ_NEW_SMALL_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(adc_close_obj, 1, adc_close); STATIC mp_obj_t adc_readVoltage(size_t n_args, const mp_obj_t *args) { adc_dev_t *adc_device = NULL; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return MP_OBJ_NEW_SMALL_INT(-MP_E2BIG); } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_adc_obj_t *driver_obj = (mp_adc_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return MP_OBJ_NEW_SMALL_INT (-MP_EINVAL); } adc_device = py_board_get_node_by_handle(MODULE_ADC, &(driver_obj->adc_handle)); if (NULL == adc_device) { LOGE(LOG_TAG, "%s: py_board_get_node_by_handle failed;\n", __func__); return MP_OBJ_NEW_SMALL_INT (-MP_ENODEV); } int32_t adc_value = -1; int32_t ret = aos_hal_adc_voltage_value_get(adc_device, &adc_value, 0); if (ret > 0) { /* Make sure return negative value on error.*/ return MP_OBJ_NEW_SMALL_INT(-ret); } else if (ret < 0) { return MP_OBJ_NEW_SMALL_INT(ret); } else { return MP_OBJ_NEW_SMALL_INT(adc_value); } } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(adc_readVoltage_obj, 1, adc_readVoltage); STATIC mp_obj_t adc_readRaw(size_t n_args, const mp_obj_t *args) { adc_dev_t *adc_device = NULL; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return MP_OBJ_NEW_SMALL_INT(-MP_E2BIG); } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_adc_obj_t *driver_obj = (mp_adc_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return MP_OBJ_NEW_SMALL_INT(-MP_EINVAL); } adc_device = py_board_get_node_by_handle(MODULE_ADC, &(driver_obj->adc_handle)); if (NULL == adc_device) { LOGE(LOG_TAG, "%s: py_board_get_node_by_handle failed;\n", __func__); return MP_OBJ_NEW_SMALL_INT(-MP_ENODEV); } int32_t adc_value = -1; int32_t ret = aos_hal_adc_raw_value_get(adc_device, &adc_value, 0); if (ret != 0) { return MP_OBJ_NEW_SMALL_INT(ret); } else { return MP_OBJ_NEW_SMALL_INT(adc_value); } } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(adc_readRaw_obj, 1, adc_readRaw); STATIC mp_obj_t adc_getHwParam(size_t n_args, const mp_obj_t *args) { adc_dev_t *adc_device = NULL; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return MP_OBJ_NEW_SMALL_INT(-MP_E2BIG); } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_adc_obj_t *driver_obj = (mp_adc_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return MP_OBJ_NEW_SMALL_INT(-MP_EINVAL); } adc_device = py_board_get_node_by_handle(MODULE_ADC, &(driver_obj->adc_handle)); if (NULL == adc_device) { LOGE(LOG_TAG, "%s: py_board_get_node_by_handle failed;\n", __func__); return MP_OBJ_NEW_SMALL_INT(-MP_ENODEV); } mp_obj_t dict = mp_obj_new_dict(2); mp_obj_dict_store(MP_OBJ_FROM_PTR(dict), mp_obj_new_str("ADC_WIDTH_BIT", strlen("ADC_WIDTH_BIT")), mp_obj_new_int(adc_device->config.adc_width)); mp_obj_dict_store(MP_OBJ_FROM_PTR(dict), mp_obj_new_str("ADC_ATTEN_DB", strlen("ADC_ATTEN_DB")), mp_obj_new_int(adc_device->config.adc_atten)); return dict; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(adc_getHwParam_obj, 1, adc_getHwParam); STATIC const mp_rom_map_elem_t adc_locals_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ADC) }, { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&adc_open_obj) }, { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&adc_close_obj) }, { MP_ROM_QSTR(MP_QSTR_readVoltage), MP_ROM_PTR(&adc_readVoltage_obj) }, { MP_ROM_QSTR(MP_QSTR_readRaw), MP_ROM_PTR(&adc_readRaw_obj) }, { MP_ROM_QSTR(MP_QSTR_getHwParam), MP_ROM_PTR(&adc_getHwParam_obj) }, }; STATIC MP_DEFINE_CONST_DICT(adc_locals_dict, adc_locals_dict_table); const mp_obj_type_t driver_adc_type = { .base = { &mp_type_type }, .name = MP_QSTR_ADC, .print = adc_obj_print, .make_new = adc_obj_make_new, .locals_dict = (mp_obj_dict_t *)&adc_locals_dict, };
YifuLiu/AliOS-Things
components/py_engine/modules/driver/adc.c
C
apache-2.0
8,092
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #define CONFIG_LOGMACRO_DETAILS #include "board_mgr.h" #include <fcntl.h> #include <stdarg.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "aos/list.h" #include "aos_hal_adc.h" #include "aos_hal_gpio.h" #include "aos_hal_i2c.h" #include "aos_hal_pwm.h" #include "aos_hal_spi.h" #include "aos_hal_uart.h" #include "aos_hal_wdg.h" #include "board_config.h" #include "cJSON.h" #include "ulog/ulog.h" #define LOG_TAG "BOARD_MGR" #define DRIVER_NAME "driver.json" // extern int py_repl_config; int py_repl_config = 0; typedef struct parse_json { char *marker_name; addon_module_m module; int8_t (*fn)(cJSON *, char *); } parse_json_t; typedef struct board_item { addon_module_m module; item_handle_t handle; char *name_id; void *node; uint8_t status; } board_item_t; typedef struct board_mgr { uint32_t item_size; board_item_t **item; } board_mgr_t; typedef struct page_entry { char *page; dlist_t node; } page_entry_t; static board_mgr_t g_board_mgr = { 0, NULL }; static dlist_t g_pages_list; static int8_t board_add_new_item(addon_module_m module, char *name_id, void *node); static board_mgr_t *board_get_handle(void) { return &g_board_mgr; } static void board_set_gpio_default(gpio_dev_t *gpio_device) { gpio_params_t *priv = (gpio_params_t *)gpio_device->priv; if (NULL == gpio_device || NULL == priv) { return; } gpio_device->port = -1; gpio_device->config = OUTPUT_PUSH_PULL; #ifndef ESP_PLATFORM gpio_device->gpioc = NULL; gpio_device->gpioc_index = 0; gpio_device->pin_index = 0; #endif priv->irq_mode = 0; priv->js_cb_ref = 0; priv->reserved = NULL; } static int8_t board_parse_gpio(cJSON *gpio, char *id) { int index = 0; int8_t ret = -1; cJSON *port = NULL; cJSON *item = NULL; cJSON *dir = NULL; cJSON *pull = NULL; cJSON *intMode = NULL; gpio_dev_t device; gpio_params_t *priv = NULL; gpio_config_t *config = (gpio_config_t *)&device.config; int8_t size = 1; if (size <= 0) { return BOARD_ERR_SIZE_INVALID; } while (index < size) { if ((priv = (gpio_params_t *)aos_calloc(1, sizeof(gpio_params_t))) == NULL) { LOGE(LOG_TAG, "malloc failed"); return BOARD_ERR_NO_MEM; } item = gpio; index += 1; if (NULL == item || NULL == id) { continue; } port = cJSON_GetObjectItem(item, MARKER_PORT); if (NULL == port || cJSON_Number != port->type) { continue; } device.priv = priv; board_set_gpio_default(&device); dir = cJSON_GetObjectItem(item, GPIO_DIR); pull = cJSON_GetObjectItem(item, GPIO_PULL); intMode = cJSON_GetObjectItem(item, GPIO_INTMODE); if (NULL != dir && cJSON_String == dir->type && NULL != pull && cJSON_String == pull->type) { if (strcmp(dir->valuestring, GPIO_DIR_INPUT) == 0) { if (strcmp(GPIO_PULL_DOWN, pull->valuestring) == 0) *config = INPUT_PULL_DOWN; else if (strcmp(GPIO_PULL_UP, pull->valuestring) == 0) *config = INPUT_PULL_UP; else if (strcmp(GPIO_PULL_OPEN, pull->valuestring) == 0) *config = INPUT_HIGH_IMPEDANCE; } else if (strcmp(dir->valuestring, GPIO_DIR_OUTPUT) == 0) { if (strcmp(GPIO_PULL_DOWN, pull->valuestring) == 0) *config = OUTPUT_PUSH_PULL; else if (strcmp(GPIO_PULL_UP, pull->valuestring) == 0) *config = OUTPUT_OPEN_DRAIN_PULL_UP; else if (strcmp(GPIO_PUSH_PULL, pull->valuestring) == 0) *config = OUTPUT_PUSH_PULL; else if (strcmp(GPIO_PULL_OPEN, pull->valuestring) == 0) *config = OUTPUT_OPEN_DRAIN_NO_PULL; } else if (strcmp(dir->valuestring, GPIO_DIR_IRQ) == 0) { *config = IRQ_MODE; if (strcmp(GPIO_PULL_DOWN, pull->valuestring) == 0) *config = INPUT_PULL_DOWN; else if (strcmp(GPIO_PULL_UP, pull->valuestring) == 0) *config = INPUT_PULL_UP; else if (strcmp(GPIO_PULL_OPEN, pull->valuestring) == 0) *config = INPUT_HIGH_IMPEDANCE; if (strcmp(GPIO_INT_RISING, intMode->valuestring) == 0) priv->irq_mode = IRQ_TRIGGER_RISING_EDGE; else if (strcmp(GPIO_INT_FALLING, intMode->valuestring) == 0) priv->irq_mode = IRQ_TRIGGER_FALLING_EDGE; else if (strcmp(GPIO_INT_BOTH, intMode->valuestring) == 0) priv->irq_mode = IRQ_TRIGGER_BOTH_EDGES; else if (strcmp(GPIO_INT_HIGH_LEVEL, intMode->valuestring) == 0) priv->irq_mode = IRQ_TRIGGER_LEVEL_HIGH; else if (strcmp(GPIO_INT_LOW_LEVEL, intMode->valuestring) == 0) priv->irq_mode = IRQ_TRIGGER_LEVEL_LOW; } else if (strcmp(dir->valuestring, GPIO_DIR_ANALOG) == 0) { *config = ANALOG_MODE; } } gpio_dev_t *new_gpio = (gpio_dev_t *)aos_calloc(1, sizeof(*new_gpio)); if (NULL == new_gpio) { continue; } device.port = port->valueint; char *gpio_id = strdup(id); memcpy(new_gpio, &device, sizeof(gpio_dev_t)); ret = board_add_new_item(MODULE_GPIO, gpio_id, new_gpio); if (0 == ret) { continue; } if (NULL != gpio_id) { aos_free(gpio_id); gpio_id = NULL; } if (NULL != new_gpio) { aos_free(new_gpio); new_gpio = NULL; aos_free(priv); priv = NULL; } } return BOARD_ERR_NONE; } static void board_set_uart_default(uart_dev_t *uart_device) { if (NULL == uart_device) { return; } uart_device->port = 0; uart_device->priv = NULL; uart_device->config.baud_rate = 115200; uart_device->config.data_width = DATA_WIDTH_8BIT; uart_device->config.flow_control = FLOW_CONTROL_DISABLED; uart_device->config.parity = NO_PARITY; uart_device->config.stop_bits = STOP_BITS_1; uart_device->config.mode = MODE_TX_RX; } static int8_t board_parse_uart(cJSON *uart, char *id) { int index = 0; int8_t ret = -1; cJSON *port = NULL; cJSON *item = NULL; cJSON *temp = NULL; uart_dev_t device; uart_config_t *config = (uart_config_t *)&device.config; int8_t size = 1; if (size <= 0) { return BOARD_ERR_SIZE_INVALID; } while (index < size) { item = uart; index += 1; if (NULL == item) { continue; } port = cJSON_GetObjectItem(item, MARKER_PORT); if (NULL == port || cJSON_Number != port->type) { continue; } board_set_uart_default(&device); temp = cJSON_GetObjectItem(item, UART_DATA_WIDTH); if (NULL != temp && cJSON_Number == temp->type) { int32_t width = temp->valueint; switch (width) { case 5: config->data_width = DATA_WIDTH_5BIT; break; case 6: config->data_width = DATA_WIDTH_6BIT; break; case 7: config->data_width = DATA_WIDTH_7BIT; break; case 8: config->data_width = DATA_WIDTH_8BIT; break; default: break; } } temp = cJSON_GetObjectItem(item, UART_BAUD_RATE); if (NULL != temp && cJSON_Number == temp->type) { config->baud_rate = temp->valueint; } temp = cJSON_GetObjectItem(item, UART_STOP_BITS); if (NULL != temp && cJSON_Number == temp->type) { int32_t stopbits = temp->valueint; switch (stopbits) { case 1: config->stop_bits = STOP_BITS_1; break; case 2: config->stop_bits = STOP_BITS_2; default: break; } } temp = cJSON_GetObjectItem(item, UART_FLOW_CONTROL); if (NULL != temp && cJSON_String == temp->type) { if (strcmp(temp->valuestring, UART_FC_DISABLE) == 0) { config->flow_control = FLOW_CONTROL_DISABLED; } else if (strcmp(temp->valuestring, UART_FC_CTS) == 0) { config->flow_control = FLOW_CONTROL_CTS; } else if (strcmp(temp->valuestring, UART_FC_RTS) == 0) { config->flow_control = FLOW_CONTROL_RTS; } else if (strcmp(temp->valuestring, UART_FC_RTSCTS) == 0) { config->flow_control = FLOW_CONTROL_CTS_RTS; } } temp = cJSON_GetObjectItem(item, UART_PARITY_CONFIG); if (NULL != temp && cJSON_String == temp->type) { if (strcmp(temp->valuestring, UART_PARITY_NONE) == 0) { config->parity = NO_PARITY; } else if (strcmp(temp->valuestring, UART_PARITY_ODD) == 0) { config->parity = ODD_PARITY; } else if (strcmp(temp->valuestring, UART_PARITY_EVEN) == 0) { config->parity = EVEN_PARITY; } } uart_dev_t *new_uart = (uart_dev_t *)aos_calloc(1, sizeof(*new_uart)); if (NULL == new_uart) { continue; } device.port = port->valueint; char *uart_id = strdup(id); *new_uart = device; ret = board_add_new_item(MODULE_UART, uart_id, new_uart); LOGD(LOG_TAG, "*** add item: %s", uart_id); if (0 == ret) { continue; } if (NULL != uart_id) { aos_free(uart_id); uart_id = NULL; } if (NULL != new_uart) { aos_free(new_uart); new_uart = NULL; } } return BOARD_ERR_NONE; } static void board_set_i2c_default(i2c_dev_t *i2c_device) { if (NULL == i2c_device) { return; } i2c_device->port = 0; i2c_device->priv = NULL; i2c_device->config.address_width = 7; i2c_device->config.freq = 100000; i2c_device->config.mode = I2C_MODE_MASTER; i2c_device->config.dev_addr = 0xFF; } static int8_t board_parse_i2c(cJSON *i2c, char *id) { int index = 0; int8_t ret = -1; cJSON *port = NULL; cJSON *item = NULL; cJSON *temp = NULL; uint32_t timeout; i2c_dev_t device; i2c_config_t *config = (i2c_config_t *)&device.config; int8_t size = 1; if (size <= 0) { return BOARD_ERR_SIZE_INVALID; } while (index < size) { item = i2c; index += 1; if (NULL == item) { continue; } port = cJSON_GetObjectItem(item, MARKER_PORT); if (NULL == port || cJSON_Number != port->type) { continue; } board_set_i2c_default(&device); temp = cJSON_GetObjectItem(item, I2C_ADDR_WIDTH); if (NULL != temp && cJSON_Number == temp->type) { switch (temp->valueint) { case 7: config->address_width = I2C_HAL_ADDRESS_WIDTH_7BIT; break; case 10: config->address_width = I2C_HAL_ADDRESS_WIDTH_10BIT; break; default: break; } } temp = cJSON_GetObjectItem(item, I2C_FREQ); if (NULL != temp && cJSON_Number == temp->type) { config->freq = temp->valueint; } temp = cJSON_GetObjectItem(item, I2C_MODE); if (NULL != temp && cJSON_String == temp->type) { if (strcmp(temp->valuestring, I2C_MASTER) == 0) { config->mode = I2C_MODE_MASTER; } else if (strcmp(temp->valuestring, I2C_SLAVE) == 0) { config->mode = I2C_MODE_SLAVE; } } temp = cJSON_GetObjectItem(item, I2C_TIMEOUT); if (NULL != temp && cJSON_Number == temp->type) { timeout = temp->valueint; } temp = cJSON_GetObjectItem(item, I2C_ADDR_DEV); if (NULL != temp && cJSON_Number == temp->type) { config->dev_addr = temp->valueint; } i2c_dev_t *new_i2c = (i2c_dev_t *)aos_calloc(1, sizeof(*new_i2c)); if (NULL == new_i2c) { continue; } device.port = port->valueint; char *i2c_id = strdup(id); *new_i2c = device; ret = board_add_new_item(MODULE_I2C, i2c_id, new_i2c); if (0 == ret) { continue; } if (NULL != i2c_id) { aos_free(i2c_id); i2c_id = NULL; } if (NULL != new_i2c) { aos_free(new_i2c); new_i2c = NULL; } } return BOARD_ERR_NONE; } static void board_set_spi_default(spi_dev_t *spi_device) { if (NULL == spi_device) { return; } spi_device->port = 0; spi_device->priv = NULL; spi_device->config.data_size = SPI_DATA_SIZE_8BIT; spi_device->config.mode = SPI_WORK_MODE_3; spi_device->config.cs = SPI_CS_DIS; spi_device->config.role = SPI_ROLE_MASTER; spi_device->config.serial_len = 0; spi_device->config.firstbit = SPI_FIRSTBIT_MSB; spi_device->config.t_mode = SPI_TRANSFER_NORMAL; spi_device->config.freq = 2000000; } static int8_t board_parse_spi(cJSON *spi, char *id) { int index = 0; int8_t ret = -1; cJSON *port = NULL; cJSON *item = NULL; cJSON *temp = NULL; spi_dev_t device; spi_config_t *config = (spi_config_t *)&device.config; int8_t size = 1; if (size <= 0) { return BOARD_ERR_SIZE_INVALID; } while (index < size) { item = spi; index += 1; if (NULL == item) { continue; } port = cJSON_GetObjectItem(item, MARKER_PORT); if (NULL == port || cJSON_Number != port->type) { continue; } board_set_spi_default(&device); temp = cJSON_GetObjectItem(item, SPI_MODE); if (NULL != temp && cJSON_String == temp->type) { if (strcmp(temp->valuestring, SPI_MODE_MASTER) == 0) { config->role = HAL_SPI_MODE_MASTER; } else if (strcmp(temp->valuestring, SPI_MODE_SLAVE) == 0) { config->role = HAL_SPI_MODE_SLAVE; } } temp = cJSON_GetObjectItem(item, SPI_FREQ); if (NULL != temp && cJSON_Number == temp->type) { config->freq = temp->valueint; } temp = cJSON_GetObjectItem(item, SPI_CPOL_CPHA); if (NULL != temp && cJSON_Number == temp->type) { config->mode = temp->valueint; } spi_dev_t *new_spi = (spi_dev_t *)aos_calloc(1, sizeof(*new_spi)); if (NULL == new_spi) { continue; } device.port = port->valueint; char *spi_id = strdup(id); *new_spi = device; ret = board_add_new_item(MODULE_SPI, spi_id, new_spi); if (0 == ret) { continue; } if (NULL != spi_id) { aos_free(spi_id); spi_id = NULL; } if (NULL != new_spi) { aos_free(new_spi); new_spi = NULL; } } return BOARD_ERR_NONE; } static void board_set_pwm_default(pwm_dev_t *pwm_device) { if (NULL == pwm_device) { return; } pwm_device->port = 0; pwm_device->priv = NULL; pwm_device->config.freq = 1; pwm_device->config.duty_cycle = 100; } static int8_t board_parse_pwm(cJSON *pwm, char *id) { int index = 0; int8_t ret = -1; cJSON *port = NULL; cJSON *item = NULL; cJSON *temp = NULL; pwm_dev_t device; pwm_config_t *config = (pwm_config_t *)&device.config; int8_t size = 1; if (size <= 0) { return BOARD_ERR_SIZE_INVALID; } while (index < size) { item = pwm; index += 1; if (NULL == item) { continue; } port = cJSON_GetObjectItem(item, MARKER_PORT); if (NULL == port || cJSON_Number != port->type) { continue; } board_set_pwm_default(&device); pwm_dev_t *new_pwm = (pwm_dev_t *)aos_calloc(1, sizeof(*new_pwm)); if (NULL == new_pwm) { continue; } device.port = port->valueint; char *pwm_id = strdup(id); *new_pwm = device; ret = board_add_new_item(MODULE_PWM, pwm_id, new_pwm); if (0 == ret) { continue; } if (NULL != pwm_id) { aos_free(pwm_id); pwm_id = NULL; } if (NULL != new_pwm) { aos_free(new_pwm); new_pwm = NULL; } } return BOARD_ERR_NONE; } static void board_set_adc_default(adc_dev_t *adc_device) { if (NULL == adc_device) { return; } adc_device->port = 0; adc_device->priv = NULL; adc_device->config.sampling_cycle = 12000000; adc_device->config.adc_atten = 0; adc_device->config.adc_width = 3; } static int8_t board_parse_adc(cJSON *adc, char *id) { int index = 0; int8_t ret = -1; cJSON *port = NULL; cJSON *item = NULL; cJSON *temp = NULL; adc_dev_t device; adc_config_t *config = (adc_config_t *)&device.config; int8_t size = 1; if (size <= 0) { return BOARD_ERR_SIZE_INVALID; } while (index < size) { item = adc; index += 1; if (NULL == item) { continue; } port = cJSON_GetObjectItem(item, MARKER_PORT); if (NULL == port || cJSON_Number != port->type) { continue; } board_set_adc_default(&device); temp = cJSON_GetObjectItem(item, ADC_SAMPLING); if (NULL != temp && cJSON_Number == temp->type) { config->sampling_cycle = temp->valueint; } temp = cJSON_GetObjectItem(item, ADC_ATTEN); if (NULL != temp && cJSON_Number == temp->type) { config->adc_atten = temp->valueint; } temp = cJSON_GetObjectItem(item, ADC_WIDTH); if (NULL != temp && cJSON_Number == temp->type) { config->adc_width = temp->valueint; } adc_dev_t *new_adc = (adc_dev_t *)aos_calloc(1, sizeof(*new_adc)); if (NULL == new_adc) { continue; } device.port = port->valueint; char *adc_id = strdup(id); *new_adc = device; ret = board_add_new_item(MODULE_ADC, adc_id, new_adc); if (0 == ret) { continue; } if (NULL != adc_id) { aos_free(adc_id); adc_id = NULL; } if (NULL != new_adc) { aos_free(new_adc); new_adc = NULL; } } return BOARD_ERR_NONE; } static void board_set_modbus_default(modbus_dev_t *mdobus_device) { if (NULL == mdobus_device) { return; } mdobus_device->mode = MBMODE_SERIAL; mdobus_device->port = MODBUS_SERIAL_PORT; mdobus_device->baudrate = 9600; mdobus_device->parity = 0; mdobus_device->timeout = 200; } static int8_t board_parse_modbus(cJSON *modbus, char *id) { int32_t index = 0; int8_t ret = -1; cJSON *port = NULL; cJSON *item = NULL; cJSON *temp = NULL; modbus_dev_t device; int8_t size = 1; if (size <= 0) { return BOARD_ERR_SIZE_INVALID; } while (index < size) { item = modbus; index += 1; if (NULL == item) { continue; } port = cJSON_GetObjectItem(item, MARKER_PORT); if (NULL == port || cJSON_Number != port->type) { continue; } board_set_modbus_default(&device); temp = cJSON_GetObjectItem(item, MODBUS_MODE); if (NULL != temp && cJSON_Number == temp->type) { device.mode = temp->valueint; } if (device.mode == MBMODE_SERIAL) { temp = cJSON_GetObjectItem(item, MODBUS_PORT); if (NULL != temp && cJSON_Number == temp->type) { device.port = temp->valueint; } temp = cJSON_GetObjectItem(item, MODBUS_BAUDRATE); if (NULL != temp && cJSON_Number == temp->type) { device.baudrate = temp->valueint; } temp = cJSON_GetObjectItem(item, MODBUS_PARITY); if (NULL != temp && cJSON_Number == temp->type) { device.parity = temp->valueint; } temp = cJSON_GetObjectItem(item, MODBUS_TIMEOUT); if (NULL != temp && cJSON_Number == temp->type) { device.timeout = temp->valueint; } } modbus_dev_t *new_modbus = (modbus_dev_t *)aos_calloc(1, sizeof(*new_modbus)); if (NULL == new_modbus) { continue; } const char *modbus_id = strdup(id); *new_modbus = device; ret = board_add_new_item(MODULE_MODBUS, modbus_id, new_modbus); if (0 == ret) { continue; } if (NULL != modbus_id) { aos_free(modbus_id); modbus_id = NULL; } if (NULL != new_modbus) { aos_free(new_modbus); new_modbus = NULL; } } return BOARD_ERR_NONE; } static void board_set_wdt_default(wdg_dev_t *wdt_device) { if (NULL == wdt_device) { return; } wdt_device->config.timeout = 3; } static int8_t board_parse_wdt(cJSON *wdt, char *id) { int32_t ret = -1; cJSON *temp = NULL; wdg_dev_t *new_wdt = NULL; const char *wdt_id = NULL; if ((NULL == wdt) || (NULL == id)) return BOARD_ERR_INVALID_ARG; new_wdt = aos_malloc(sizeof(*new_wdt)); if (NULL == new_wdt) return BOARD_ERR_NO_MEM; board_set_wdt_default(new_wdt); temp = cJSON_GetObjectItem(wdt, WDT_TIMEOUT); if (NULL != temp && cJSON_Number == temp->type) new_wdt->config.timeout = temp->valueint; wdt_id = strdup(id); ret = board_add_new_item(MODULE_WDT, wdt_id, new_wdt); if (0 == ret) { return BOARD_ERR_NONE; } if (NULL != wdt_id) { aos_free(wdt_id); wdt_id = NULL; } if (NULL != new_wdt) { aos_free(new_wdt); new_wdt = NULL; } return ret; } char *board_get_json_buff(const char *json_path) { void *json_data = NULL; int len = 0; int json_fd = -1; if (NULL == json_path) { LOGE(LOG_TAG, "json_path NULL\n"); return (NULL); } json_fd = open(json_path, O_RDONLY); if (json_fd < 0) { LOGE(LOG_TAG, "failed to open json file:%s\n", json_path); return (NULL); } len = lseek(json_fd, 0, SEEK_END); if (len < 0) { LOGE(LOG_TAG, "failed to seek file\n"); return (NULL); } json_data = aos_calloc(len + 1, sizeof(char)); if (NULL == json_data) { close(json_fd); LOGE(LOG_TAG, "failed to calloc data for json_data\n"); return (NULL); } lseek(json_fd, 0, SEEK_SET); read(json_fd, json_data, len); close(json_fd); return json_data; } static parse_json_t g_parse_json[] = { { MARKER_UART, MODULE_UART, board_parse_uart }, { MARKER_GPIO, MODULE_GPIO, board_parse_gpio }, { MARKER_PWM, MODULE_PWM, board_parse_pwm }, { MARKER_I2C, MODULE_I2C, board_parse_i2c }, { MARKER_SPI, MODULE_SPI, board_parse_spi }, { MARKER_ADC, MODULE_ADC, board_parse_adc }, { MARKER_MODBUS, MODULE_MODBUS, board_parse_modbus }, { MARKER_WDT, MODULE_WDT, board_parse_wdt }, { NULL, MODULE_NUMS, NULL }, }; static int32_t board_parse_json_buff(const char *json_buff) { cJSON *root = NULL; cJSON *page = NULL, *pages = NULL; cJSON *io = NULL; cJSON *debug = NULL; cJSON *repl = NULL; cJSON *item = NULL; cJSON *child = NULL; parse_json_t *parser_handle = NULL; if (NULL == json_buff) { LOGE(LOG_TAG, "json_buff NULL\n"); return BOARD_ERR_INVALID_ARG; } root = cJSON_Parse(json_buff); if (NULL == root) { LOGE(LOG_TAG, "json parse fail\n"); return BOARD_ERR_JSON_PARSE; } /* debugLevel configuration */ if ((debug = cJSON_GetObjectItem(root, APP_CONFIG_DEBUG)) != NULL) { /* parsing debugLevel configuration */ if (!cJSON_IsString(debug)) { LOGE(LOG_TAG, "debugLevel not string"); goto parse_end; } LOGD(LOG_TAG, "get debugLevel:%s\n", debug->valuestring); if (strcmp(debug->valuestring, "DEBUG") == 0) { aos_set_log_level(LOG_DEBUG); } else if (strcmp(debug->valuestring, "INFO") == 0) { aos_set_log_level(LOG_INFO); } else if (strcmp(debug->valuestring, "WARN") == 0) { aos_set_log_level(LOG_WARNING); } else if (strcmp(debug->valuestring, "ERROR") == 0) { aos_set_log_level(LOG_ERR); } else if (strcmp(debug->valuestring, "FATAL") == 0) { aos_set_log_level(LOG_CRIT); } else { LOGD(LOG_TAG, "debugLevel error, set to default: 'ERROR'"); aos_set_log_level(LOG_ERR); } } else { LOGD(LOG_TAG, "No debugLevel configuration in app.json, set to default: 'ERROR'"); } /* page configuration */ if ((pages = cJSON_GetObjectItem(root, APP_CONFIG_PAGES)) != NULL) { /* parsing io configuration */ if (!cJSON_IsArray(pages)) { LOGE(LOG_TAG, "Pages entries need array"); goto parse_end; } dlist_init(&g_pages_list); cJSON_ArrayForEach(page, pages) { if (!cJSON_IsString(page)) { LOGE(LOG_TAG, "page not string"); goto parse_end; } LOGD(LOG_TAG, "get page:%s", page->valuestring); /* add page to dlink */ page_entry_t *page_entry = (page_entry_t *)aos_malloc(sizeof(page_entry_t)); page_entry->page = strdup(page->valuestring); /* don't forget to free */ dlist_add_tail(&page_entry->node, &g_pages_list); } } else { LOGD(LOG_TAG, "No pages configuration in app.json"); } /* repl configuration */ if ((repl = cJSON_GetObjectItem(root, APP_CONFIG_REPL)) != NULL) { /* parsing debugLevel configuration */ if (!cJSON_IsString(repl)) { LOGE(LOG_TAG, "repl not string"); goto parse_end; } LOGD(LOG_TAG, "get app repl config is:%s", repl->valuestring); if (strcmp(repl->valuestring, "disable") == 0) { py_repl_config = 0; } else if (strcmp(repl->valuestring, "enable") == 0) { py_repl_config = 1; } else { LOGD(LOG_TAG, "repl configuration is wrong, set to default: 'enable'"); py_repl_config = 1; } } else { LOGD(LOG_TAG, "No repl configuration in app.json, set to default: 'enable'"); } /* net configuration */ /* TODO */ /* io configuration */ if ((io = cJSON_GetObjectItem(root, APP_CONFIG_IO)) != NULL) { /* parsing io configuration */ child = io->child; while (NULL != child) { item = cJSON_GetObjectItem(child, MARKER_ID); if (NULL == item || cJSON_String != item->type) { child = child->next; continue; } parser_handle = &g_parse_json[0]; while (NULL != parser_handle->marker_name) { if (0 == strcmp(item->valuestring, parser_handle->marker_name)) { parser_handle->fn(child, child->string); } parser_handle += 1; } child = child->next; } } else { LOGE(LOG_TAG, "No io configuration in app.json"); } cJSON_Delete(root); return BOARD_ERR_NONE; parse_end: cJSON_Delete(root); return BOARD_ERR_JSON_PARSE; } static void *board_get_items(addon_module_m module, item_handle_t *handle, const char *name_id) { board_mgr_t *mgr_handle = board_get_handle(); board_item_t *item = NULL; if (NULL == handle && NULL == name_id) { LOGE(LOG_TAG, "handle or name_id null\n"); return (NULL); } uint32_t i = 0; for (i = 0; i < mgr_handle->item_size; ++i) { item = mgr_handle->item[i]; if (module != item->module) { continue; } if (NULL != handle && item->handle.handle != handle->handle) { continue; } if (NULL != name_id && 0 != strcmp(item->name_id, name_id)) { continue; } return (item); } return (NULL); } static int8_t board_add_new_item(addon_module_m module, char *name_id, void *node) { board_mgr_t *mgr_handle = board_get_handle(); if (NULL == name_id || NULL == node) { return BOARD_ERR_INVALID_ARG; } if (NULL != board_get_items(module, NULL, name_id)) { LOGE(LOG_TAG, "board_get_items failed, name_id = %s\n", name_id); return BOARD_ERR_NODE_NOT_EXIST; } board_item_t *new_item = (board_item_t *)aos_calloc(1, sizeof(*new_item)); if (NULL == new_item) { return BOARD_ERR_NO_MEM; } void *addr = aos_realloc(mgr_handle->item, sizeof(board_item_t *) * (mgr_handle->item_size + 1)); if (NULL == addr) { goto out; } new_item->module = module; new_item->name_id = name_id; new_item->handle.handle = (void *)new_item; new_item->node = node; new_item->status = 0; mgr_handle->item = addr; mgr_handle->item[mgr_handle->item_size] = new_item; mgr_handle->item_size += 1; return BOARD_ERR_NONE; out: if (NULL != new_item) { aos_free(new_item); new_item = NULL; } return BOARD_ERR_NO_MEM; } int8_t py_board_attach_item(addon_module_m module, const char *name_id, item_handle_t *out) { board_item_t *item = NULL; if (NULL == name_id) { return BOARD_ERR_INVALID_ARG; } item = board_get_items(module, NULL, name_id); if (NULL == item) { LOGE(LOG_TAG, "board_get_items failed, name_id = %s\n", name_id); return BOARD_ERR_NODE_NOT_EXIST; } item->status = 1; *out = item->handle; return BOARD_ERR_NONE; } int8_t py_board_disattach_item(addon_module_m module, item_handle_t *handle) { board_item_t *item = NULL; if (NULL == handle) { return BOARD_ERR_INVALID_ARG; } item = board_get_items(module, handle, NULL); if (NULL == item) { return BOARD_ERR_NODE_NOT_EXIST; } item->status = 0; return BOARD_ERR_NONE; } int8_t py_board_check_attach_status(addon_module_m module, item_handle_t *handle) { board_item_t *item = NULL; if (NULL == handle) { return BOARD_ERR_NONE; } item = board_get_items(module, handle, NULL); if (NULL == item) { return BOARD_ERR_NONE; } return item->status; } void *py_board_get_node_by_name(addon_module_m module, const char *name_id) { board_item_t *item = NULL; if (NULL == name_id) { return NULL; } item = board_get_items(module, NULL, name_id); if (NULL == item || 0 == item->status) { LOGE(LOG_TAG, "board_get_items failed, name_id = %s\n", name_id); return NULL; } return item->node; } void *py_board_get_node_by_handle(addon_module_m module, item_handle_t *handle) { board_item_t *item = NULL; if (NULL == handle) return NULL; item = board_get_items(module, handle, NULL); if (NULL == item || 0 == item->status) { return NULL; } return item->node; } static bool board_init_flag = false; int32_t py_board_mgr_init() { int32_t ret = -1; char *json = NULL; int json_fd = -1; char *board_json_path = NULL; char *data_root_path = AMP_FS_ROOT_DIR "/board.json"; char *sdcard_root_path = AMP_FS_EXT_ROOT_DIR "/board.json"; char *data_board_json_path = MP_FS_ROOT_DIR "/lib/board.json"; char *sdcard_board_json_path = MP_FS_EXT_ROOT_DIR "/lib/board.json"; if (board_init_flag != false) { LOGD(LOG_TAG, "board config haas been loaded\n"); return BOARD_ERR_NONE; } memset(&g_board_mgr, 0x00, sizeof(g_board_mgr)); if (board_json_path == NULL) { json_fd = open(data_root_path, O_RDONLY); if (json_fd >= 0) { close(json_fd); board_json_path = data_root_path; } } json_fd = open(sdcard_root_path, O_RDONLY); if (json_fd >= 0) { close(json_fd); board_json_path = sdcard_root_path; } if (board_json_path == NULL) { json_fd = open(data_board_json_path, O_RDONLY); if (json_fd >= 0) { close(json_fd); board_json_path = data_board_json_path; } } if (board_json_path == NULL) { board_json_path = sdcard_board_json_path; } LOGD(LOG_TAG, "board_json_path = %s;\n", board_json_path); json = board_get_json_buff(board_json_path); if (NULL == json) { LOGD(LOG_TAG, "default board config is null"); return ret; } // return BOARD_ERR_NONE; ret = board_parse_json_buff(json); aos_free(json); json = NULL; if (0 == ret) { board_init_flag = true; } return ret; }
YifuLiu/AliOS-Things
components/py_engine/modules/driver/board_mgr.c
C
apache-2.0
33,774
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "py/builtin.h" #include "py/mperrno.h" #include "py/obj.h" #include "py/runtime.h" #include "ulog/ulog.h" #define LOG_TAG "DRIVER_CAN" extern const mp_obj_type_t driver_can_type; #define CAN_JSON_CONFIG_PATH "/data/python/config/can.json" // this is the actual C-structure for our new object typedef struct { // base represents some basic information, like type mp_obj_base_t Base; // a member created by us char *ModuleName; } mp_can_obj_t; void can_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { LOGD(LOG_TAG, "entern %s;\n", __func__); mp_can_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_printf(print, "ModuleName(%s)", self->ModuleName); } STATIC mp_obj_t can_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s;\n", __func__); mp_can_obj_t *driver_obj = m_new_obj(mp_can_obj_t); if (!driver_obj) { mp_raise_OSError(MP_EINVAL); } driver_obj->Base.type = &driver_can_type; driver_obj->ModuleName = "can"; return MP_OBJ_FROM_PTR(driver_obj); } STATIC mp_obj_t obj_open(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void *instance = NULL; if (n_args < 5) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_can_obj_t *driver_obj = (mp_can_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(can_obj_open, 5, obj_open); STATIC mp_obj_t obj_close(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void *instance = NULL; if (n_args < 5) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_can_obj_t *driver_obj = (mp_can_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(can_obj_close, 5, obj_close); STATIC mp_obj_t obj_send(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void *instance = NULL; if (n_args < 5) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_can_obj_t *driver_obj = (mp_can_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(can_obj_send, 5, obj_send); STATIC mp_obj_t obj_receive(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void *instance = NULL; if (n_args < 5) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_can_obj_t *driver_obj = (mp_can_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(can_obj_receive, 5, obj_receive); STATIC const mp_rom_map_elem_t can_locals_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_CAN) }, { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&can_obj_open) }, { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&can_obj_close) }, { MP_ROM_QSTR(MP_QSTR_send), MP_ROM_PTR(&can_obj_send) }, { MP_ROM_QSTR(MP_QSTR_receive), MP_ROM_PTR(&can_obj_receive) }, }; STATIC MP_DEFINE_CONST_DICT(can_locals_dict, can_locals_dict_table); const mp_obj_type_t driver_can_type = { .base = { &mp_type_type }, .name = MP_QSTR_CAN, .print = can_obj_print, .make_new = can_obj_make_new, .locals_dict = (mp_obj_dict_t *)&can_locals_dict, };
YifuLiu/AliOS-Things
components/py_engine/modules/driver/can.c
C
apache-2.0
4,605
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "py/builtin.h" #include "py/mperrno.h" #include "py/obj.h" #include "py/runtime.h" #include "ulog/ulog.h" #define LOG_TAG "DRIVER_CRYPTO" extern const mp_obj_type_t driver_crypto_type; // this is the actual C-structure for our new object typedef struct { // base represents some basic information, like type mp_obj_base_t Base; // a member created by us char *ModuleName; } mp_crypto_obj_t; void crypto_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { LOGD(LOG_TAG, "entern %s;\n", __func__); mp_crypto_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_printf(print, "ModuleName(%s)", self->ModuleName); } STATIC mp_obj_t crypto_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s;\n", __func__); mp_crypto_obj_t *driver_obj = m_new_obj(mp_crypto_obj_t); if (!driver_obj) { mp_raise_OSError(MP_EINVAL); } driver_obj->Base.type = &driver_crypto_type; driver_obj->ModuleName = "crypto"; return MP_OBJ_FROM_PTR(driver_obj); } STATIC mp_obj_t obj_open(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void *instance = NULL; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_crypto_obj_t *driver_obj = (mp_crypto_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(crypto_obj_open, 1, obj_open); STATIC mp_obj_t obj_close(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void *instance = NULL; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_crypto_obj_t *driver_obj = (mp_crypto_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(crypto_obj_close, 1, obj_close); STATIC mp_obj_t obj_md5(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; uint8_t result[16] = { 0 }; char md5[33] = { 0 }; int i = 0; if (n_args < 2) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_crypto_obj_t *driver_obj = (mp_crypto_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } mp_buffer_info_t src; mp_get_buffer_raise(args[1], &src, MP_BUFFER_READ); LOGD(LOG_TAG, "%s:src.buf = %p;src.len = %d;\n", __func__, src.buf, src.len); // mbedtls_md5(src.buf, src.len, result); for (i = 0; i < 16; ++i) { // num2hex(result[i], &md5[2 * i]); } LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(crypto_obj_md5, 2, obj_md5); STATIC mp_obj_t obj_encrypt(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void *instance = NULL; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_crypto_obj_t *driver_obj = (mp_crypto_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(crypto_obj_encrypt, 1, obj_encrypt); STATIC mp_obj_t obj_decrypt(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void *instance = NULL; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_crypto_obj_t *driver_obj = (mp_crypto_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(crypto_obj_decrypt, 1, obj_decrypt); STATIC const mp_rom_map_elem_t crypto_locals_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_Crypto) }, { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&crypto_obj_open) }, { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&crypto_obj_close) }, { MP_ROM_QSTR(MP_QSTR_md5), MP_ROM_PTR(&crypto_obj_md5) }, { MP_ROM_QSTR(MP_QSTR_encrypt), MP_ROM_PTR(&crypto_obj_encrypt) }, { MP_ROM_QSTR(MP_QSTR_decrypt), MP_ROM_PTR(&crypto_obj_decrypt) }, }; STATIC MP_DEFINE_CONST_DICT(crypto_locals_dict, crypto_locals_dict_table); const mp_obj_type_t driver_crypto_type = { .base = { &mp_type_type }, .name = MP_QSTR_Crypto, .print = crypto_obj_print, .make_new = crypto_obj_make_new, .locals_dict = (mp_obj_dict_t *)&crypto_locals_dict, };
YifuLiu/AliOS-Things
components/py_engine/modules/driver/crypto.c
C
apache-2.0
5,757
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "aos_hal_dac.h" #include "board_mgr.h" #include "py/builtin.h" #include "py/mperrno.h" #include "py/obj.h" #include "py/runtime.h" #include "ulog/ulog.h" #define LOG_TAG "DRIVER_DAC" extern const mp_obj_type_t driver_dac_type; // this is the actual C-structure for our new object typedef struct { // base represents some basic information, like type mp_obj_base_t Base; // a member created by us char *ModuleName; item_handle_t dac_handle; } mp_dac_obj_t; void dac_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { LOGD(LOG_TAG, "entern %s;\n", __func__); mp_dac_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_printf(print, "ModuleName(%s)", self->ModuleName); } STATIC mp_obj_t dac_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s;\n", __func__); mp_dac_obj_t *driver_obj = m_new_obj(mp_dac_obj_t); if (!driver_obj) { mp_raise_OSError(MP_EINVAL); } driver_obj->Base.type = &driver_dac_type; driver_obj->ModuleName = "dac"; driver_obj->dac_handle.handle = NULL; return MP_OBJ_FROM_PTR(driver_obj); } STATIC mp_obj_t obj_open(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; dac_dev_t *dac_device = NULL; if (n_args < 2) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_dac_obj_t *driver_obj = (mp_dac_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } char *id = (char *)mp_obj_str_get_str(args[1]); LOGD(LOG_TAG, "%s: id =%s;\n", __func__, id); if (id == NULL) { LOGE(LOG_TAG, "%s:illegal par id =%s;\n", __func__, id); return mp_const_none; } ret = py_board_mgr_init(); if (ret != 0) { LOGE(LOG_TAG, "%s:py_board_mgr_init failed\n", __func__); return mp_const_none; } LOGD(LOG_TAG, "%s: py_board_mgr_init ret = %d;\n", __func__, ret); ret = py_board_attach_item(MODULE_DAC, id, &(driver_obj->dac_handle)); if (ret != 0) { LOGE(LOG_TAG, "%s: py_board_attach_item failed ret = %d;\n", __func__, ret); goto out; } dac_device = py_board_get_node_by_handle(MODULE_DAC, &(driver_obj->dac_handle)); if (NULL == dac_device) { LOGE(LOG_TAG, "%s: py_board_get_node_by_handle failed;\n", __func__); goto out; } LOGD(LOG_TAG, "%s: port = %d;\n", __func__, dac_device->port); #if 0 ret = hal_dac_init(dac_device); if (ret != 0) { LOGE(LOG_TAG, "hal_dac_init failed\n"); goto out; } ret = hal_dac_start(dac_device, dac_device->port); if (ret != 0) { LOGE(LOG_TAG, "hal_dac_start failed\n"); } #endif out: if (0 != ret) { py_board_disattach_item(MODULE_DAC, &(driver_obj->dac_handle)); } LOGD(LOG_TAG, "%s:out\n", __func__); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(dac_obj_open, 2, obj_open); STATIC mp_obj_t obj_close(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; dac_dev_t *dac_device = NULL; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_dac_obj_t *driver_obj = (mp_dac_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } dac_device = py_board_get_node_by_handle(MODULE_DAC, &(driver_obj->dac_handle)); if (NULL == dac_device) { LOGE(LOG_TAG, "%s: py_board_get_node_by_handle failed;\n", __func__); return mp_const_none; } // hal_dac_stop(dac_device, dac_device->port); // ret = hal_dac_finalize(dac_device); py_board_disattach_item(MODULE_DAC, &(driver_obj->dac_handle)); LOGD(LOG_TAG, "%s:out\n", __func__); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(dac_obj_close, 1, obj_close); STATIC mp_obj_t obj_getVol(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; dac_dev_t *dac_device = NULL; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_dac_obj_t *driver_obj = (mp_dac_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } dac_device = py_board_get_node_by_handle(MODULE_DAC, &(driver_obj->dac_handle)); if (NULL == dac_device) { LOGE(LOG_TAG, "%s: py_board_get_node_by_handle failed;\n", __func__); return mp_const_none; } // ret = (int)hal_dac_get_value(dac_device, dac_device->port); LOGD(LOG_TAG, "%s:out\n", __func__); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(dac_obj_getVol, 1, obj_getVol); STATIC mp_obj_t obj_setVol(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; uint32_t voltage = 0; dac_dev_t *dac_device = NULL; if (n_args < 2) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_dac_obj_t *driver_obj = (mp_dac_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } dac_device = py_board_get_node_by_handle(MODULE_DAC, &(driver_obj->dac_handle)); if (NULL == dac_device) { LOGE(LOG_TAG, "%s: py_board_get_node_by_handle failed;\n", __func__); return mp_const_none; } voltage = (uint32_t)mp_obj_get_int(args[1]); // ret = hal_dac_set_value(dac_device, dac_device->port, voltage); LOGD(LOG_TAG, "%s:out\n", __func__); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(dac_obj_setVol, 2, obj_setVol); STATIC const mp_rom_map_elem_t dac_locals_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_DAC) }, { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&dac_obj_open) }, { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&dac_obj_close) }, { MP_ROM_QSTR(MP_QSTR_getVol), MP_ROM_PTR(&dac_obj_getVol) }, { MP_ROM_QSTR(MP_QSTR_setVol), MP_ROM_PTR(&dac_obj_setVol) }, }; STATIC MP_DEFINE_CONST_DICT(dac_locals_dict, dac_locals_dict_table); const mp_obj_type_t driver_dac_type = { .base = { &mp_type_type }, .name = MP_QSTR_DAC, .print = dac_obj_print, .make_new = dac_obj_make_new, .locals_dict = (mp_obj_dict_t *)&dac_locals_dict, };
YifuLiu/AliOS-Things
components/py_engine/modules/driver/dac.c
C
apache-2.0
7,105
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "aos_hal_gpio.h" #include "board_mgr.h" #include "py/builtin.h" #include "py/gc.h" #include "py/mperrno.h" #include "py/obj.h" #include "py/runtime.h" #include "py/stackctrl.h" #include "ulog/ulog.h" #define LOG_TAG "DRIVER_GPIO" extern const mp_obj_type_t driver_gpio_type; typedef enum { IRQ_RISING_EDGE = 0x1, /**< Interrupt triggered at input signal's rising edge */ IRQ_FALLING_EDGE = 0x2, /**< Interrupt triggered at input signal's falling edge */ IRQ_BOTH_EDGES = IRQ_RISING_EDGE | IRQ_FALLING_EDGE, } gpio_irq_trigger_params_t; // this is the actual C-structure for our new object typedef struct { // base represents some basic information, like type mp_obj_base_t Base; // a member created by us char *ModuleName; item_handle_t gpio_handle; gpio_dev_t *gpio_device; mp_obj_t callback; } mp_gpio_obj_t; void gpio_driver_irq_handler(int polarity, void *arg) { mp_gpio_obj_t *self = (mp_gpio_obj_t *)arg; int32_t level = aos_hal_gpio_get(self->gpio_device); gpio_params_t *priv = (gpio_params_t *)self->gpio_device->priv; uintptr_t tmp = (uintptr_t)priv->reserved; priv->reserved = (void *)(tmp + 1); if (!callback_to_python_LoBo(self->callback, MP_OBJ_NEW_SMALL_INT(level), NULL)) LOGE(LOG_TAG, "%s: callback_to_python_LoBo failed\n", __func__); } void gpio_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { mp_gpio_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_printf(print, "ModuleName(%s)", self->ModuleName); } STATIC mp_obj_t gpio_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_gpio_obj_t *driver_obj = m_new_obj(mp_gpio_obj_t); if (!driver_obj) { LOGE(LOG_TAG, "%s: alloc mem failed;\n", __func__); mp_raise_OSError(ENOMEM); } driver_obj->Base.type = &driver_gpio_type; driver_obj->ModuleName = "gpio"; driver_obj->gpio_handle.handle = NULL; driver_obj->gpio_device = NULL; return MP_OBJ_FROM_PTR(driver_obj); } STATIC mp_obj_t obj_open(size_t n_args, const mp_obj_t *args) { if (n_args != 2) { LOGE(LOG_TAG, "%s: illegal args;\n", __func__); mp_raise_OSError(EINVAL); } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_gpio_obj_t *driver_obj = (mp_gpio_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); mp_raise_OSError(EINVAL); } if (driver_obj->gpio_device != NULL) { LOGE(LOG_TAG, "device hass opened\n"); return MP_ROM_INT(-ENXIO); } int ret = -1; gpio_dev_t *gpio_device = NULL; char *id = (char *)mp_obj_str_get_str(args[1]); if (id == NULL) { LOGE(LOG_TAG, "%s:illegal par id =%s;\n", __func__, id); mp_raise_OSError(EINVAL); } if (py_board_mgr_init() != 0) { LOGE(LOG_TAG, "%s:py_board_mgr_init failed\n", __func__); mp_raise_OSError(EINVAL); } if (py_board_attach_item(MODULE_GPIO, id, &(driver_obj->gpio_handle)) != 0) { LOGE(LOG_TAG, "%s: py_board_attach_item failed ret = %d;\n", __func__, ret); py_board_disattach_item(MODULE_GPIO, &(driver_obj->gpio_handle)); mp_raise_OSError(EINVAL); } gpio_device = py_board_get_node_by_handle(MODULE_GPIO, &(driver_obj->gpio_handle)); if (NULL == gpio_device) { LOGE(LOG_TAG, "%s: py_board_get_node_by_handle failed;\n", __func__); py_board_disattach_item(MODULE_GPIO, &(driver_obj->gpio_handle)); gpio_device = NULL; mp_raise_OSError(EINVAL); } driver_obj->gpio_device = gpio_device; gpio_params_t *priv = (gpio_params_t *)gpio_device->priv; LOGE(LOG_TAG, "%s: gpio %u irq count %lu\n", __func__, gpio_device->port, (unsigned long)priv->reserved); ret = aos_hal_gpio_init(gpio_device); if (ret) { mp_raise_OSError(ret); } return MP_ROM_INT(0); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(gpio_obj_open, 2, obj_open); STATIC mp_obj_t obj_close(size_t n_args, const mp_obj_t *args) { int ret = -1; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return MP_ROM_INT(-EINVAL); } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_gpio_obj_t *driver_obj = (mp_gpio_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return MP_ROM_INT(-EINVAL); } if (NULL == driver_obj->gpio_device) { LOGE(LOG_TAG, "driver_obj has closed\n"); return MP_ROM_INT(-ENXIO); } ret = aos_hal_gpio_finalize(driver_obj->gpio_device); if (ret != 0) { LOGE(LOG_TAG, "%s: aos_hal_gpio_finalize failed;\n", __func__); return MP_ROM_INT(-EINVAL); } py_board_disattach_item(MODULE_GPIO, &(driver_obj->gpio_handle)); driver_obj->gpio_device = NULL; return MP_ROM_INT(0); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(gpio_obj_close, 1, obj_close); STATIC mp_obj_t obj_read(size_t n_args, const mp_obj_t *args) { int ret = -1; uint32_t level = 0; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return MP_ROM_INT(-EINVAL); } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_gpio_obj_t *driver_obj = (mp_gpio_obj_t *)self; if (NULL == driver_obj) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return MP_ROM_INT(-EINVAL); } if (NULL == driver_obj->gpio_device) { LOGE(LOG_TAG, "driver_obj has closed\n"); return MP_ROM_INT(-ENXIO); } level = aos_hal_gpio_get(driver_obj->gpio_device); return MP_ROM_INT(level); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(gpio_obj_read, 1, obj_read); STATIC mp_obj_t obj_write(size_t n_args, const mp_obj_t *args) { int ret = -1; uint32_t level = 0; if (n_args < 2) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return MP_ROM_INT(-EINVAL); } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_gpio_obj_t *driver_obj = (mp_gpio_obj_t *)self; if (NULL == driver_obj) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return MP_ROM_INT(-EINVAL); } if (NULL == driver_obj->gpio_device) { LOGE(LOG_TAG, "driver_obj has closed\n"); return MP_ROM_INT(-ENXIO); } level = (uint32_t)mp_obj_get_int(args[1]); if (level) { ret = aos_hal_gpio_output_high(driver_obj->gpio_device); } else { ret = aos_hal_gpio_output_low(driver_obj->gpio_device); } return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(gpio_obj_write, 2, obj_write); STATIC mp_obj_t obj_toggle(size_t n_args, const mp_obj_t *args) { int ret = -1; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return MP_ROM_INT(-EINVAL); } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_gpio_obj_t *driver_obj = (mp_gpio_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return MP_ROM_INT(-EINVAL); } ret = aos_hal_gpio_output_toggle(driver_obj->gpio_device); if (ret == -1) { LOGE(LOG_TAG, "aos_hal_gpio_output_toggle failed\n"); } return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(gpio_obj_toggle, 1, obj_toggle); STATIC mp_obj_t obj_on(size_t n_args, const mp_obj_t *args) { int ret = -1; uint32_t irq_edge = 0; if (n_args < 2 || args[1] == mp_const_none) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return MP_ROM_INT(-EINVAL); } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_gpio_obj_t *driver_obj = (mp_gpio_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return MP_ROM_INT(-EINVAL); } if (driver_obj->gpio_device == NULL) { LOGE(LOG_TAG, "driver_obj has closed\n"); return MP_ROM_INT(-ENXIO); } driver_obj->callback = args[1]; // judge callback function if callback == None disable IQR // ret = aos_hal_gpio_clear_irq(driver_obj->gpio_device); gpio_params_t *priv = (gpio_params_t *)driver_obj->gpio_device->priv; driver_obj->callback = args[1]; if (n_args == 3) { irq_edge = (uint32_t)mp_obj_get_int(args[2]); } else { irq_edge = priv->irq_mode; } ret = aos_hal_gpio_enable_irq(driver_obj->gpio_device, (int8_t)irq_edge, gpio_driver_irq_handler, (void *)driver_obj); if (ret < 0) { LOGE(LOG_TAG, "%s:aos_hal_gpio_enable_irq failed, %d\n", __func__, ret); } LOGE(LOG_TAG, "%s: gpio %u irq count %lu\n", __func__, driver_obj->gpio_device->port, (unsigned long)priv->reserved); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(gpio_on_obj, 2, 3, obj_on); STATIC mp_obj_t gpio_port(size_t n_args, const mp_obj_t *args) { mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_gpio_obj_t *driver_obj = (mp_gpio_obj_t *)self; if (NULL == driver_obj) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return MP_ROM_INT(-EINVAL); } if (NULL == driver_obj->gpio_device) { LOGE(LOG_TAG, "driver_obj has closed\n"); return MP_ROM_INT(-ENXIO); } return MP_ROM_INT(driver_obj->gpio_device->port); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(gpio_obj_port, 1, gpio_port); STATIC const mp_rom_map_elem_t gpio_locals_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_GPIO) }, { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&gpio_obj_open) }, { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&gpio_obj_close) }, { MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&gpio_obj_read) }, { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&gpio_obj_write) }, { MP_ROM_QSTR(MP_QSTR_port), MP_ROM_PTR(&gpio_obj_port) }, { MP_ROM_QSTR(MP_QSTR_on), MP_ROM_PTR(&gpio_on_obj) }, { MP_ROM_QSTR(MP_QSTR_RisingEdge), MP_ROM_INT(IRQ_RISING_EDGE) }, { MP_ROM_QSTR(MP_QSTR_FallingEdge), MP_ROM_INT(IRQ_FALLING_EDGE) }, }; STATIC MP_DEFINE_CONST_DICT(gpio_locals_dict, gpio_locals_dict_table); const mp_obj_type_t driver_gpio_type = { .base = { &mp_type_type }, .name = MP_QSTR_GPIO, .print = gpio_obj_print, .make_new = gpio_obj_make_new, .locals_dict = (mp_obj_dict_t *)&gpio_locals_dict, };
YifuLiu/AliOS-Things
components/py_engine/modules/driver/gpio.c
C
apache-2.0
10,553
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "aos_hal_i2c.h" #include "board_mgr.h" #include "py/builtin.h" #include "py/mperrno.h" #include "py/obj.h" #include "py/runtime.h" #include "ulog/ulog.h" #define LOG_TAG "DRIVER_I2C" #define I2C_CHECK_PARAMS(count) \ if (n_args < count) { \ LOGE(LOG_TAG, "%s: args count is illegal: n_args = %d;\n", __func__, n_args); \ return MP_OBJ_NEW_SMALL_INT(-MP_E2BIG); \ } \ mp_i2c_obj_t *driver_obj = (mp_i2c_obj_t *)MP_OBJ_TO_PTR(args[0]); \ do { \ if (driver_obj == NULL) { \ LOGE(LOG_TAG, "driver_obj[I2C] is NULL\n"); \ return MP_OBJ_NEW_SMALL_INT(-MP_EINVAL); \ } \ } while (0) #define I2C_NODE_GET() \ i2c_dev_t *i2c_device = py_board_get_node_by_handle(MODULE_I2C, &(driver_obj->i2c_handle)); \ do { \ if (NULL == i2c_device) { \ LOGE(LOG_TAG, "%s: py_board_get_node_by_handle failed;\n", __func__); \ py_board_disattach_item(MODULE_I2C, &(driver_obj->i2c_handle)); \ return MP_OBJ_NEW_SMALL_INT(-MP_ENXIO); \ } \ } while (0) #define I2C_TIMEOUT_MS (0xFFFFFF) #define I2C_CHANNEL_MAX (4) extern const mp_obj_type_t driver_i2c_type; // this is the actual C-structure for our new object typedef struct { // base represents some basic information, like type mp_obj_base_t Base; const char *ModuleName; item_handle_t i2c_handle; } mp_i2c_obj_t; void i2c_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { mp_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_printf(print, "ModuleName(%s)", self->ModuleName); } STATIC mp_obj_t i2c_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_i2c_obj_t *driver_obj = m_new_obj(mp_i2c_obj_t); if (!driver_obj) { mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("Memory malloc failed")); } memset(driver_obj, 0, sizeof(mp_i2c_obj_t)); driver_obj->Base.type = &driver_i2c_type; driver_obj->ModuleName = "i2c"; return MP_OBJ_FROM_PTR(driver_obj); } STATIC mp_obj_t i2c_open(size_t n_args, const mp_obj_t *args) { I2C_CHECK_PARAMS(2); int ret = -1; char *id = NULL; if (mp_obj_is_str(args[1])) { id = (char *)mp_obj_str_get_str(args[1]); } else { LOGE(LOG_TAG, "%s: 2nd arg should be string\n", __func__); return MP_OBJ_NEW_SMALL_INT(-MP_EINVAL); } ret = py_board_mgr_init(); if (ret != 0) { LOGE(LOG_TAG, "%s:py_board_mgr_init failed\n", __func__); return MP_OBJ_NEW_SMALL_INT(-MP_ENOENT); } ret = py_board_attach_item(MODULE_I2C, id, &(driver_obj->i2c_handle)); if (ret != 0) { LOGE(LOG_TAG, "%s: py_board_attach_item[%s] failed, ret = %d;\n", __func__, id, ret); goto fail; } I2C_NODE_GET(); LOGD(LOG_TAG, "%s: port = %d;\n", __func__, i2c_device->port); LOGD(LOG_TAG, "%s: address_width = %d;\n", __func__, i2c_device->config.address_width); LOGD(LOG_TAG, "%s: freq = %d;\n", __func__, i2c_device->config.freq); LOGD(LOG_TAG, "%s: mode = %d;\n", __func__, i2c_device->config.mode); LOGD(LOG_TAG, "%s: dev_addr = %d;\n", __func__, i2c_device->config.dev_addr); if (i2c_device->port >= I2C_CHANNEL_MAX) { ret = -MP_ENODEV; goto fail; } ret = aos_hal_i2c_init(i2c_device); fail: if (ret != 0) py_board_disattach_item(MODULE_I2C, &(driver_obj->i2c_handle)); return MP_OBJ_NEW_SMALL_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(i2c_open_obj, 2, i2c_open); STATIC mp_obj_t i2c_close(size_t n_args, const mp_obj_t *args) { int ret = -1; I2C_CHECK_PARAMS(1); I2C_NODE_GET(); ret = aos_hal_i2c_finalize(i2c_device); if (ret == 0) py_board_disattach_item(MODULE_I2C, &(driver_obj->i2c_handle)); if (ret < 0) { LOGE(LOG_TAG, "%s: i2c_close failed\n", __func__); } return MP_OBJ_NEW_SMALL_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(i2c_close_obj, 1, i2c_close); STATIC mp_obj_t i2c_write(size_t n_args, const mp_obj_t *args) { I2C_CHECK_PARAMS(2); I2C_NODE_GET(); mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_READ); mp_int_t ret = aos_hal_i2c_master_send(i2c_device, i2c_device->config.dev_addr, bufinfo.buf, bufinfo.len, I2C_TIMEOUT_MS); if (ret < 0) { LOGE(LOG_TAG, "aos_hal_i2c_master_send failed\n"); return MP_OBJ_NEW_SMALL_INT(ret); } else { return MP_OBJ_NEW_SMALL_INT(bufinfo.len); } } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(i2c_write_obj, 2, i2c_write); STATIC mp_obj_t i2c_read(size_t n_args, const mp_obj_t *args) { I2C_CHECK_PARAMS(2); I2C_NODE_GET(); mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_WRITE); mp_int_t ret = aos_hal_i2c_master_recv(i2c_device, i2c_device->config.dev_addr, bufinfo.buf, bufinfo.len, I2C_TIMEOUT_MS); if (ret < 0) { LOGE(LOG_TAG, "aos_hal_i2c_master_recv failed\n"); return MP_OBJ_NEW_SMALL_INT(ret); } else { return MP_OBJ_NEW_SMALL_INT(bufinfo.len); } } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(i2c_read_obj, 2, i2c_read); STATIC mp_obj_t i2c_memWrite(size_t n_args, const mp_obj_t *args) { I2C_CHECK_PARAMS(4); I2C_NODE_GET(); mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_READ); mp_uint_t mem_addr = mp_obj_get_int(args[2]); mp_uint_t mem_addr_size = mp_obj_get_int(args[3]); mp_int_t ret = aos_hal_i2c_mem_write(i2c_device, i2c_device->config.dev_addr, mem_addr, mem_addr_size, bufinfo.buf, bufinfo.len, I2C_TIMEOUT_MS); if (ret < 0) { LOGE(LOG_TAG, "aos_hal_i2c_mem_write failed\n"); return MP_OBJ_NEW_SMALL_INT(ret); } else { return MP_OBJ_NEW_SMALL_INT(bufinfo.len); } } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(i2c_memWrite_obj, 4, i2c_memWrite); STATIC mp_obj_t i2c_memRead(size_t n_args, const mp_obj_t *args) { I2C_CHECK_PARAMS(4); I2C_NODE_GET(); mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_WRITE); mp_uint_t mem_addr = mp_obj_get_int(args[2]); mp_uint_t mem_addr_size = mp_obj_get_int(args[3]); mp_int_t ret = aos_hal_i2c_mem_read(i2c_device, i2c_device->config.dev_addr, mem_addr, mem_addr_size, bufinfo.buf, bufinfo.len, I2C_TIMEOUT_MS); if (ret < 0) { LOGE(LOG_TAG, "aos_hal_i2c_mem_read failed\n"); return MP_OBJ_NEW_SMALL_INT(ret); } else { return MP_OBJ_NEW_SMALL_INT(bufinfo.len); } } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(i2c_memRead_obj, 4, i2c_memRead); STATIC const mp_rom_map_elem_t i2c_locals_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_I2C) }, { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&i2c_open_obj) }, { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&i2c_close_obj) }, { MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&i2c_read_obj) }, { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&i2c_write_obj) }, { MP_ROM_QSTR(MP_QSTR_memRead), MP_ROM_PTR(&i2c_memRead_obj) }, { MP_ROM_QSTR(MP_QSTR_memWrite), MP_ROM_PTR(&i2c_memWrite_obj) }, }; STATIC MP_DEFINE_CONST_DICT(i2c_locals_dict, i2c_locals_dict_table); const mp_obj_type_t driver_i2c_type = { .base = { &mp_type_type }, .name = MP_QSTR_I2C, .print = i2c_obj_print, .make_new = i2c_obj_make_new, .locals_dict = (mp_obj_dict_t *)&i2c_locals_dict, };
YifuLiu/AliOS-Things
components/py_engine/modules/driver/i2c.c
C
apache-2.0
8,489
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "py/builtin.h" #include "py/mperrno.h" #include "py/obj.h" #include "py/runtime.h" #include "ulog/ulog.h" #define LOG_TAG "DRIVER_IR" extern const mp_obj_type_t driver_ir_type; // this is the actual C-structure for our new object typedef struct { // base represents some basic information, like type mp_obj_base_t Base; // a member created by us char *ModuleName; } mp_ir_obj_t; void ir_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { LOGD(LOG_TAG, "entern %s;\n", __func__); mp_ir_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_printf(print, "ModuleName(%s)", self->ModuleName); } STATIC mp_obj_t ir_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s;\n", __func__); mp_ir_obj_t *driver_obj = m_new_obj(mp_ir_obj_t); if (!driver_obj) { mp_raise_OSError(MP_EINVAL); } driver_obj->Base.type = &driver_ir_type; driver_obj->ModuleName = "ir"; return MP_OBJ_FROM_PTR(driver_obj); } STATIC mp_obj_t obj_open(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void *instance = NULL; if (n_args < 5) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_ir_obj_t *driver_obj = (mp_ir_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(ir_obj_open, 5, obj_open); STATIC mp_obj_t obj_close(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void *instance = NULL; if (n_args < 5) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_ir_obj_t *driver_obj = (mp_ir_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(ir_obj_close, 5, obj_close); STATIC mp_obj_t obj_on(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void *instance = NULL; if (n_args < 5) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_ir_obj_t *driver_obj = (mp_ir_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(ir_obj_on, 5, obj_on); STATIC mp_obj_t obj_send(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void *instance = NULL; if (n_args < 5) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_ir_obj_t *driver_obj = (mp_ir_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(ir_obj_send, 5, obj_send); STATIC mp_obj_t obj_learn(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void *instance = NULL; if (n_args < 5) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_ir_obj_t *driver_obj = (mp_ir_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(ir_obj_learn, 5, obj_learn); STATIC const mp_rom_map_elem_t ir_locals_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_IR) }, { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&ir_obj_open) }, { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&ir_obj_close) }, { MP_ROM_QSTR(MP_QSTR_on), MP_ROM_PTR(&ir_obj_on) }, { MP_ROM_QSTR(MP_QSTR_send), MP_ROM_PTR(&ir_obj_send) }, { MP_ROM_QSTR(MP_QSTR_learn), MP_ROM_PTR(&ir_obj_learn) }, }; STATIC MP_DEFINE_CONST_DICT(ir_locals_dict, ir_locals_dict_table); const mp_obj_type_t driver_ir_type = { .base = { &mp_type_type }, .name = MP_QSTR_IR, .print = ir_obj_print, .make_new = ir_obj_make_new, .locals_dict = (mp_obj_dict_t *)&ir_locals_dict, };
YifuLiu/AliOS-Things
components/py_engine/modules/driver/ir.c
C
apache-2.0
5,232
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "py/builtin.h" #include "py/mperrno.h" #include "py/obj.h" #include "py/runtime.h" #include "ulog/ulog.h" #define LOG_TAG "DRIVER_KEYPAD" extern const mp_obj_type_t driver_keypad_type; // this is the actual C-structure for our new object typedef struct { // base represents some basic information, like type mp_obj_base_t Base; // a member created by us char *ModuleName; } mp_keypad_obj_t; void keypad_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { LOGD(LOG_TAG, "entern %s;\n", __func__); mp_keypad_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_printf(print, "ModuleName(%s)", self->ModuleName); } STATIC mp_obj_t keypad_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s;\n", __func__); mp_keypad_obj_t *driver_obj = m_new_obj(mp_keypad_obj_t); if (!driver_obj) { mp_raise_OSError(MP_EINVAL); } driver_obj->Base.type = &driver_keypad_type; driver_obj->ModuleName = "keypad"; return MP_OBJ_FROM_PTR(driver_obj); } STATIC mp_obj_t obj_open(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void *instance = NULL; if (n_args < 5) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_keypad_obj_t *driver_obj = (mp_keypad_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(keypad_obj_open, 5, obj_open); STATIC mp_obj_t obj_close(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void *instance = NULL; if (n_args < 5) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_keypad_obj_t *driver_obj = (mp_keypad_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(keypad_obj_close, 5, obj_close); STATIC mp_obj_t obj_on(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void *instance = NULL; if (n_args < 5) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_keypad_obj_t *driver_obj = (mp_keypad_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(keypad_obj_on, 5, obj_on); STATIC const mp_rom_map_elem_t keypad_locals_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_KeyPad) }, { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&keypad_obj_open) }, { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&keypad_obj_close) }, { MP_ROM_QSTR(MP_QSTR_on), MP_ROM_PTR(&keypad_obj_on) }, }; STATIC MP_DEFINE_CONST_DICT(keypad_locals_dict, keypad_locals_dict_table); const mp_obj_type_t driver_keypad_type = { .base = { &mp_type_type }, .name = MP_QSTR_KeyPad, .print = keypad_obj_print, .make_new = keypad_obj_make_new, .locals_dict = (mp_obj_dict_t *)&keypad_locals_dict, };
YifuLiu/AliOS-Things
components/py_engine/modules/driver/keypad.c
C
apache-2.0
3,865
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "py/builtin.h" #include "py/mperrno.h" #include "py/obj.h" #include "py/runtime.h" #include "ulog/ulog.h" #define LOG_TAG "DRIVER_LOCATION" extern const mp_obj_type_t driver_location_type; #define LOCATION_JSON_CONFIG_PATH "/data/python/config/location.json" // this is the actual C-structure for our new object typedef struct { // base represents some basic information, like type mp_obj_base_t Base; // a member created by us char *ModuleName; } mp_location_obj_t; void location_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { LOGD(LOG_TAG, "entern %s;\n", __func__); mp_location_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_printf(print, "ModuleName(%s)", self->ModuleName); } STATIC mp_obj_t location_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s;\n", __func__); mp_location_obj_t *driver_obj = m_new_obj(mp_location_obj_t); if (!driver_obj) { mp_raise_OSError(MP_EINVAL); } driver_obj->Base.type = &driver_location_type; driver_obj->ModuleName = "location"; return MP_OBJ_FROM_PTR(driver_obj); } STATIC mp_obj_t obj_open(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void *instance = NULL; if (n_args < 5) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_location_obj_t *driver_obj = (mp_location_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(location_obj_open, 5, obj_open); STATIC mp_obj_t obj_close(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void *instance = NULL; if (n_args < 5) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_location_obj_t *driver_obj = (mp_location_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(location_obj_close, 5, obj_close); STATIC mp_obj_t obj_accessedWifi(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void *instance = NULL; if (n_args < 5) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_location_obj_t *driver_obj = (mp_location_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(location_obj_accessedWifi, 5, obj_accessedWifi); STATIC mp_obj_t obj_scannedWifi(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void *instance = NULL; if (n_args < 5) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_location_obj_t *driver_obj = (mp_location_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(location_obj_scannedWifi, 5, obj_scannedWifi); STATIC mp_obj_t obj_accessedLbs(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void *instance = NULL; if (n_args < 5) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_location_obj_t *driver_obj = (mp_location_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(location_obj_accessedLbs, 5, obj_accessedLbs); STATIC mp_obj_t obj_nearbts(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void *instance = NULL; if (n_args < 5) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_location_obj_t *driver_obj = (mp_location_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(location_obj_nearbts, 5, obj_nearbts); STATIC const mp_rom_map_elem_t location_locals_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_Location) }, { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&location_obj_open) }, { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&location_obj_close) }, { MP_ROM_QSTR(MP_QSTR_accessedWifi), MP_ROM_PTR(&location_obj_accessedWifi) }, { MP_ROM_QSTR(MP_QSTR_scannedWifi), MP_ROM_PTR(&location_obj_scannedWifi) }, { MP_ROM_QSTR(MP_QSTR_accessedLbs), MP_ROM_PTR(&location_obj_accessedLbs) }, { MP_ROM_QSTR(MP_QSTR_nearbts), MP_ROM_PTR(&location_obj_nearbts) }, }; STATIC MP_DEFINE_CONST_DICT(location_locals_dict, location_locals_dict_table); const mp_obj_type_t driver_location_type = { .base = { &mp_type_type }, .name = MP_QSTR_Location, .print = location_obj_print, .make_new = location_obj_make_new, .locals_dict = (mp_obj_dict_t *)&location_locals_dict, };
YifuLiu/AliOS-Things
components/py_engine/modules/driver/location.c
C
apache-2.0
6,434
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #if MICROPY_PY_DRIVER #include <stdio.h> #include <stdlib.h> #include <string.h> #include "py/builtin.h" #include "py/mperrno.h" #include "py/obj.h" #include "py/runtime.h" #include "drivers/dht/dht.h" // #include "ulog/ulog.h" extern const mp_obj_type_t driver_adc_type; extern const mp_obj_type_t driver_pwm_type; extern const mp_obj_type_t driver_gpio_type; extern const mp_obj_type_t driver_i2c_type; extern const mp_obj_type_t driver_spi_type; extern const mp_obj_type_t driver_uart_type; // extern const mp_obj_type_t driver_rtc_type; extern const mp_obj_type_t driver_timer_type; // extern const mp_obj_type_t driver_can_type; // extern const mp_obj_type_t driver_dac_type; // extern const mp_obj_type_t driver_ir_type; extern const mp_obj_type_t driver_wdt_type; // advanced // extern const mp_obj_type_t driver_keypad_type; // extern const mp_obj_type_t driver_location_type; // extern const mp_obj_type_t driver_und_type; // utils // extern const mp_obj_type_t driver_crypto_type; // this is the actual C-structure for our new object STATIC const mp_rom_map_elem_t driver_locals_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_driver) }, { MP_OBJ_NEW_QSTR(MP_QSTR_ADC), MP_ROM_PTR(&driver_adc_type) }, { MP_OBJ_NEW_QSTR(MP_QSTR_PWM), MP_ROM_PTR(&driver_pwm_type) }, { MP_OBJ_NEW_QSTR(MP_QSTR_GPIO), MP_ROM_PTR(&driver_gpio_type) }, { MP_OBJ_NEW_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&driver_i2c_type) }, { MP_OBJ_NEW_QSTR(MP_QSTR_UART), MP_ROM_PTR(&driver_uart_type) }, { MP_OBJ_NEW_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&driver_spi_type) }, // { MP_OBJ_NEW_QSTR(MP_QSTR_RTC), MP_ROM_PTR(&driver_rtc_type) }, { MP_OBJ_NEW_QSTR(MP_QSTR_TIMER), MP_ROM_PTR(&driver_timer_type) }, // { MP_OBJ_NEW_QSTR(MP_QSTR_CAN), MP_ROM_PTR(&driver_can_type) }, // {MP_OBJ_NEW_QSTR(MP_QSTR_DAC), MP_ROM_PTR(&driver_dac_type)}, // { MP_OBJ_NEW_QSTR(MP_QSTR_IR), MP_ROM_PTR(&driver_ir_type) }, { MP_OBJ_NEW_QSTR(MP_QSTR_WDT), MP_ROM_PTR(&driver_wdt_type) }, // { MP_OBJ_NEW_QSTR(MP_QSTR_KeyPad), MP_ROM_PTR(&driver_keypad_type) }, // { MP_OBJ_NEW_QSTR(MP_QSTR_Location), MP_ROM_PTR(&driver_location_type) }, // { MP_OBJ_NEW_QSTR(MP_QSTR_UND), MP_ROM_PTR(&driver_und_type) }, // { MP_OBJ_NEW_QSTR(MP_QSTR_Crypto), MP_ROM_PTR(&driver_crypto_type) }, { MP_ROM_QSTR(MP_QSTR_dht_readinto), MP_ROM_PTR(&dht_readinto_obj) }, }; STATIC MP_DEFINE_CONST_DICT(driver_locals_dict, driver_locals_dict_table); const mp_obj_module_t driver_module = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&driver_locals_dict, }; MP_REGISTER_MODULE(MP_QSTR_driver, driver_module, MICROPY_PY_DRIVER); #endif
YifuLiu/AliOS-Things
components/py_engine/modules/driver/moddriver.c
C
apache-2.0
2,747
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "aos_hal_pwm.h" #include "board_mgr.h" #include "py/builtin.h" #include "py/mperrno.h" #include "py/obj.h" #include "py/runtime.h" #include "ulog/ulog.h" #define LOG_TAG "DRIVER_PWM" extern const mp_obj_type_t driver_pwm_type; // this is the actual C-structure for our new object typedef struct { // base represents some basic information, like type mp_obj_base_t Base; // a member created by us char *ModuleName; item_handle_t pwm_handle; } mp_pwm_obj_t; void pwm_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { mp_pwm_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_printf(print, "ModuleName(%s)", self->ModuleName); } STATIC mp_obj_t pwm_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_pwm_obj_t *driver_obj = m_new_obj(mp_pwm_obj_t); if (!driver_obj) { mp_raise_OSError(MP_ENOMEM); } driver_obj->Base.type = &driver_pwm_type; driver_obj->ModuleName = "pwm"; driver_obj->pwm_handle.handle = NULL; return MP_OBJ_FROM_PTR(driver_obj); } STATIC mp_obj_t obj_open(size_t n_args, const mp_obj_t *args) { int ret = -1; pwm_dev_t *pwm_device = NULL; if (n_args < 2) { LOGE(LOG_TAG, "args num is illegal :n_args = %d;\n", n_args); mp_raise_OSError(MP_EINVAL); } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_pwm_obj_t *driver_obj = (mp_pwm_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); mp_raise_OSError(MP_EINVAL); } char *id = (char *)mp_obj_str_get_str(args[1]); if (id == NULL) { LOGE(LOG_TAG, "illegal id: %s;\n", id); mp_raise_OSError(MP_EINVAL); } ret = py_board_mgr_init(); if (ret != 0) { LOGE(LOG_TAG, "py_board_mgr_init failed\n"); return MP_ROM_INT(ret); ; } ret = py_board_attach_item(MODULE_PWM, id, &(driver_obj->pwm_handle)); if (ret != 0) { LOGE(LOG_TAG, "py_board_attach_item failed ret = %d;\n", ret); goto out; } pwm_device = py_board_get_node_by_handle(MODULE_PWM, &(driver_obj->pwm_handle)); if (NULL == pwm_device) { LOGE(LOG_TAG, "py_board_get_node_by_handle failed;\n"); goto out; } ret = aos_hal_pwm_init(pwm_device); return MP_ROM_INT(ret); out: if (0 != ret) { LOGE(LOG_TAG, "%s: aos_hal_pwm_init failed ret = %d;\n", __func__, ret); py_board_disattach_item(MODULE_PWM, &(driver_obj->pwm_handle)); } return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(pwm_obj_open, 2, obj_open); STATIC mp_obj_t obj_close(size_t n_args, const mp_obj_t *args) { int ret = -1; pwm_dev_t *pwm_device = NULL; if (n_args < 1) { LOGE(LOG_TAG, "args num is illegal :n_args = %d;\n", n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_pwm_obj_t *driver_obj = (mp_pwm_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return MP_ROM_INT(-MP_EINVAL); } pwm_device = py_board_get_node_by_handle(MODULE_PWM, &(driver_obj->pwm_handle)); if (NULL == pwm_device) { LOGE(LOG_TAG, "py_board_get_node_by_handle failed;\n"); return mp_const_none; } ret = aos_hal_pwm_stop(pwm_device); ret |= aos_hal_pwm_finalize(pwm_device); py_board_disattach_item(MODULE_PWM, &(driver_obj->pwm_handle)); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(pwm_obj_close, 1, obj_close); STATIC mp_obj_t obj_setOption(size_t n_args, const mp_obj_t *args) { int ret = -1; pwm_dev_t *pwm_device = NULL; if (n_args < 2) { LOGE(LOG_TAG, "args num is illegal :n_args = %d;\n", n_args); return MP_ROM_INT(-MP_EINVAL); } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_pwm_obj_t *driver_obj = (mp_pwm_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return MP_ROM_INT(-MP_EINVAL); } pwm_device = py_board_get_node_by_handle(MODULE_PWM, &(driver_obj->pwm_handle)); if (NULL == pwm_device) { LOGE(LOG_TAG, "py_board_get_node_by_handle failed;\n"); goto out; } if (!mp_obj_is_dict_or_ordereddict(args[1])) { LOGE(LOG_TAG, "%s param1 type error,param type must be dict \r\n", __func__); goto out; } mp_obj_t index = mp_obj_new_str_via_qstr("duty", 4); pwm_device->config.duty_cycle = mp_obj_get_int(mp_obj_dict_get(args[1], index)); index = mp_obj_new_str_via_qstr("freq", 4); pwm_device->config.freq = mp_obj_get_int(mp_obj_dict_get(args[1], index)); ret = aos_hal_pwm_stop(pwm_device); if (ret != 0) { LOGE(LOG_TAG, "aos_hal_pwm_stop failed\n"); goto out; } pwm_config_t para; para.duty_cycle = pwm_device->config.duty_cycle; para.freq = pwm_device->config.freq; ret = aos_hal_pwm_para_chg(pwm_device, para); if (ret != 0) { LOGE(LOG_TAG, "amp hal pwm init failed\n"); goto out; } ret = aos_hal_pwm_start(pwm_device); if (ret != 0) { LOGE(LOG_TAG, "aos_hal_pwm_start failed\n"); } out: return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(pwm_obj_setOption, 2, obj_setOption); STATIC mp_obj_t obj_getOption(size_t n_args, const mp_obj_t *args) { int ret = -1; pwm_dev_t *pwm_device = NULL; if (n_args < 1) { LOGE(LOG_TAG, "args num is illegal :n_args = %d;\n", n_args); return MP_ROM_INT(-MP_EINVAL); } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_pwm_obj_t *driver_obj = (mp_pwm_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return MP_ROM_INT(-MP_EINVAL); } pwm_device = py_board_get_node_by_handle(MODULE_PWM, &(driver_obj->pwm_handle)); if (NULL == pwm_device) { LOGE(LOG_TAG, "py_board_get_node_by_handle failed;\n"); return MP_ROM_INT(-MP_EINVAL); } mp_obj_t dict = MP_OBJ_NULL; dict = mp_obj_new_dict(2); mp_obj_dict_store(dict, mp_obj_new_str("freq", 4), mp_obj_new_int((int)(pwm_device->config.freq))); mp_obj_dict_store(dict, mp_obj_new_str("duty", 4), mp_obj_new_int((int)(pwm_device->config.duty_cycle))); return dict; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(pwm_obj_getOption, 1, obj_getOption); STATIC const mp_rom_map_elem_t pwm_locals_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_PWM) }, { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&pwm_obj_open) }, { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&pwm_obj_close) }, { MP_ROM_QSTR(MP_QSTR_getOption), MP_ROM_PTR(&pwm_obj_getOption) }, { MP_ROM_QSTR(MP_QSTR_setOption), MP_ROM_PTR(&pwm_obj_setOption) }, }; STATIC MP_DEFINE_CONST_DICT(pwm_locals_dict, pwm_locals_dict_table); const mp_obj_type_t driver_pwm_type = { .base = { &mp_type_type }, .name = MP_QSTR_PWM, .print = pwm_obj_print, .make_new = pwm_obj_make_new, .locals_dict = (mp_obj_dict_t *)&pwm_locals_dict, };
YifuLiu/AliOS-Things
components/py_engine/modules/driver/pwm.c
C
apache-2.0
7,288
#board json parse list(APPEND SOURCEFILE "${MPYADAPTORDIR}/system/driver/board_mgr.c") #driver list(APPEND SOURCEFILE "${MPYADAPTORDIR}/system/driver/keypad.c") list(APPEND SOURCEFILE "${MPYADAPTORDIR}/system/driver/location.c") list(APPEND SOURCEFILE "${MPYADAPTORDIR}/system/driver/und.c") list(APPEND SOURCEFILE "${MPYADAPTORDIR}/system/driver/crypto.c") list(APPEND SOURCEFILE "${MPYADAPTORDIR}/system/driver/adc.c") list(APPEND SOURCEFILE "${MPYADAPTORDIR}/system/driver/can.c") #list(APPEND SOURCEFILE "${MPYADAPTORDIR}/system/driver/dac.c") list(APPEND SOURCEFILE "${MPYADAPTORDIR}/system/driver/gpio.c") list(APPEND SOURCEFILE "${MPYADAPTORDIR}/system/driver/i2c.c") list(APPEND SOURCEFILE "${MPYADAPTORDIR}/system/driver/ir.c") list(APPEND SOURCEFILE "${MPYADAPTORDIR}/system/driver/pwm.c") list(APPEND SOURCEFILE "${MPYADAPTORDIR}/system/driver/rtc.c") list(APPEND SOURCEFILE "${MPYADAPTORDIR}/system/driver/spi.c") list(APPEND SOURCEFILE "${MPYADAPTORDIR}/system/driver/timer.c") list(APPEND SOURCEFILE "${MPYADAPTORDIR}/system/driver/uart.c") list(APPEND SOURCEFILE "${MPYADAPTORDIR}/system/driver/wdg.c")
YifuLiu/AliOS-Things
components/py_engine/modules/driver/py.mk
Makefile
apache-2.0
1,122
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "aos_hal_rtc.h" #include "board_mgr.h" #include "py/builtin.h" #include "py/mperrno.h" #include "py/obj.h" #include "py/runtime.h" #include "ulog/ulog.h" #define LOG_TAG "DRIVER_RTC" extern const mp_obj_type_t driver_rtc_type; //#define RTC_JSON_CONFIG_PATH "/data/python/config/rtc.json" #define RTC_JSON_CONFIG_PATH "/sdcard/python/config/rtc.json" #define RTC_TIME_FORMAT \ "{\"year\":\"%d\",\"month\":\"%d\",\"day\":\"%d\",\"hour\":\"%d\"," \ "\"minute\":\"%d\",\"second\":\"%d\"}" // this is the actual C-structure for our new object typedef struct { // base represents some basic information, like type mp_obj_base_t Base; // a member created by us char *ModuleName; rtc_dev_t rtc_dev; } mp_rtc_obj_t; void rtc_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { LOGD(LOG_TAG, "entern %s;\n", __func__); mp_rtc_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_printf(print, "ModuleName(%s)", self->ModuleName); } STATIC mp_obj_t rtc_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s;\n", __func__); mp_rtc_obj_t *driver_obj = m_new_obj(mp_rtc_obj_t); if (!driver_obj) { mp_raise_OSError(MP_EINVAL); } driver_obj->Base.type = &driver_rtc_type; driver_obj->ModuleName = "rtc"; return MP_OBJ_FROM_PTR(driver_obj); } STATIC mp_obj_t obj_open(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void *instance = NULL; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_rtc_obj_t *driver_obj = (mp_rtc_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } ret = aos_hal_rtc_init(&(driver_obj->rtc_dev)); LOGD(LOG_TAG, "%s:port: %d, format: %d;\n", __func__, driver_obj->rtc_dev.port, driver_obj->rtc_dev.config.format); if (ret != 0) { LOGE(LOG_TAG, "aos_hal_rtc_init fail!"); } LOGD(LOG_TAG, "%s:out\n", __func__); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(rtc_obj_open, 1, obj_open); STATIC mp_obj_t obj_close(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void *instance = NULL; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_rtc_obj_t *driver_obj = (mp_rtc_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } ret = aos_hal_rtc_finalize(&(driver_obj->rtc_dev)); if (ret != 0) { LOGE(LOG_TAG, "aos_hal_rtc_finalize fail!"); } LOGD(LOG_TAG, "%s:out\n", __func__); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(rtc_obj_close, 1, obj_close); STATIC mp_obj_t obj_getTime(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; rtc_time_t rtcTime; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_rtc_obj_t *driver_obj = (mp_rtc_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } ret = aos_hal_rtc_get_time(&(driver_obj->rtc_dev), &rtcTime); if (ret != 0) { LOGE(LOG_TAG, "aos_hal_rtc_get_time failed\n"); return mp_const_none; } LOGD(LOG_TAG, "year = %d; month = %d;data = %d;\n", (uint32_t)rtcTime.year, (uint32_t)rtcTime.month, (uint32_t)rtcTime.date); LOGD(LOG_TAG, "hr = %d; min = %d;sec = %d;\n", (uint32_t)rtcTime.hr, (uint32_t)rtcTime.min, (uint32_t)rtcTime.sec); mp_obj_t dict = mp_obj_new_dict(6); mp_obj_dict_store(MP_OBJ_FROM_PTR(dict), mp_obj_new_str("year", 4), mp_obj_new_int((uint32_t)rtcTime.year)); mp_obj_dict_store(MP_OBJ_FROM_PTR(dict), mp_obj_new_str("month", 5), mp_obj_new_int((uint32_t)rtcTime.month)); mp_obj_dict_store(MP_OBJ_FROM_PTR(dict), mp_obj_new_str("date", 4), mp_obj_new_int((uint32_t)rtcTime.date)); mp_obj_dict_store(MP_OBJ_FROM_PTR(dict), mp_obj_new_str("hr", 2), mp_obj_new_int((uint32_t)rtcTime.hr)); mp_obj_dict_store(MP_OBJ_FROM_PTR(dict), mp_obj_new_str("min", 3), mp_obj_new_int((uint32_t)rtcTime.min)); mp_obj_dict_store(MP_OBJ_FROM_PTR(dict), mp_obj_new_str("sec", 3), mp_obj_new_int((uint32_t)rtcTime.sec)); return dict; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(rtc_obj_getTime, 1, obj_getTime); STATIC mp_obj_t obj_setTime(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; rtc_time_t rtcTime; if (n_args < 7) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_rtc_obj_t *driver_obj = (mp_rtc_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } ret = aos_hal_rtc_get_time(&(driver_obj->rtc_dev), &rtcTime); if (ret != 0) { LOGE(LOG_TAG, "aos_hal_rtc_get_time failed\n"); return mp_const_none; } rtcTime.year = (uint8_t)mp_obj_get_int(args[1]); rtcTime.month = (uint8_t)mp_obj_get_int(args[2]); rtcTime.date = (uint8_t)mp_obj_get_int(args[3]); rtcTime.hr = (uint8_t)mp_obj_get_int(args[4]); rtcTime.min = (uint8_t)mp_obj_get_int(args[5]); rtcTime.sec = (uint8_t)mp_obj_get_int(args[6]); ret = aos_hal_rtc_set_time(&(driver_obj->rtc_dev), &rtcTime); if (ret != 0) { LOGE(LOG_TAG, "aos_hal_rtc_get_time failed\n"); } LOGD(LOG_TAG, "%s:out\n", __func__); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(rtc_obj_setTime, 7, obj_setTime); STATIC const mp_rom_map_elem_t rtc_locals_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_RTC) }, { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&rtc_obj_open) }, { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&rtc_obj_close) }, { MP_ROM_QSTR(MP_QSTR_getTime), MP_ROM_PTR(&rtc_obj_getTime) }, { MP_ROM_QSTR(MP_QSTR_setTime), MP_ROM_PTR(&rtc_obj_setTime) }, }; STATIC MP_DEFINE_CONST_DICT(rtc_locals_dict, rtc_locals_dict_table); const mp_obj_type_t driver_rtc_type = { .base = { &mp_type_type }, .name = MP_QSTR_RTC, .print = rtc_obj_print, .make_new = rtc_obj_make_new, .locals_dict = (mp_obj_dict_t *)&rtc_locals_dict, };
YifuLiu/AliOS-Things
components/py_engine/modules/driver/rtc.c
C
apache-2.0
7,329
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "aos_hal_spi.h" #include "board_mgr.h" #include "py/builtin.h" #include "py/mperrno.h" #include "py/obj.h" #include "py/runtime.h" #include "ulog/ulog.h" #define LOG_TAG "driver_spi" extern const mp_obj_type_t driver_spi_type; #define SPI_CHECK_PARAMS(cnt) \ if (n_args < cnt) { \ LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); \ return MP_OBJ_NEW_SMALL_INT(-MP_E2BIG); \ } \ mp_spi_obj_t *driver_obj = (mp_spi_obj_t *)MP_OBJ_TO_PTR(args[0]); \ do { \ if (driver_obj == NULL) { \ LOGE(LOG_TAG, "driver_obj[SPI]] is NULL\n"); \ return MP_OBJ_NEW_SMALL_INT(-MP_EINVAL); \ } \ } while (0) #define SPI_NODE_GET() \ spi_dev_t *spi_device = py_board_get_node_by_handle(MODULE_SPI, &(driver_obj->spi_handle)); \ do { \ if (NULL == spi_device) { \ LOGE(LOG_TAG, "%s: py_board_get_node_by_handle failed;\n", __func__); \ py_board_disattach_item(MODULE_SPI, &(driver_obj->spi_handle)); \ return MP_OBJ_NEW_SMALL_INT(-MP_ENXIO); \ } \ } while (0) #define SPI_TIMEOUT (1000) // this is the actual C-structure for our new object typedef struct { // base represents some basic information, like type mp_obj_base_t Base; // a member created by us char *ModuleName; item_handle_t spi_handle; } mp_spi_obj_t; void spi_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { mp_spi_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_printf(print, "ModuleName(%s)", self->ModuleName); } STATIC mp_obj_t spi_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_spi_obj_t *driver_obj = m_new_obj(mp_spi_obj_t); if (!driver_obj) { mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("Memory malloc failed")); } memset(driver_obj, 0, sizeof(mp_spi_obj_t)); driver_obj->Base.type = &driver_spi_type; driver_obj->ModuleName = "spi"; return MP_OBJ_FROM_PTR(driver_obj); } STATIC mp_obj_t spi_open(size_t n_args, const mp_obj_t *args) { mp_int_t ret = -1; SPI_CHECK_PARAMS(2); char *id = NULL; if (mp_obj_is_str(args[1])) { id = (char *)mp_obj_str_get_str(args[1]); } else { LOGE(LOG_TAG, "%s: 2nd parameter should be string\n", __func__); return MP_OBJ_NEW_SMALL_INT(-MP_EINVAL); } ret = py_board_mgr_init(); if (ret != 0) { LOGE(LOG_TAG, "%s:py_board_mgr_init failed\n", __func__); return MP_OBJ_NEW_SMALL_INT(-MP_ENOENT); } ret = py_board_attach_item(MODULE_SPI, id, &(driver_obj->spi_handle)); if (ret != 0) { LOGE(LOG_TAG, "%s: py_board_attach_item failed ret = %d\n", __func__, ret); goto fail; } SPI_NODE_GET(); LOGD(LOG_TAG, "%s: port = %d;\n", __func__, spi_device->port); LOGD(LOG_TAG, "%s: role = %d;\n", __func__, spi_device->config.role); LOGD(LOG_TAG, "%s: firstbit = %d;\n", __func__, spi_device->config.firstbit); LOGD(LOG_TAG, "%s: mode = %d;\n", __func__, spi_device->config.mode); LOGD(LOG_TAG, "%s: t_mode = %d;\n", __func__, spi_device->config.t_mode); LOGD(LOG_TAG, "%s: freq = %d;\n", __func__, spi_device->config.freq); LOGD(LOG_TAG, "%s: serial_len = %d;\n", __func__, spi_device->config.serial_len); LOGD(LOG_TAG, "%s: data_size = %d;\n", __func__, spi_device->config.data_size); LOGD(LOG_TAG, "%s: cs = %d;\n", __func__, spi_device->config.cs); ret = aos_hal_spi_init(spi_device); fail: if (ret < 0) { LOGE(LOG_TAG, "%s: spi_open failed ret = %d\n", __func__, ret); py_board_disattach_item(MODULE_SPI, &(driver_obj->spi_handle)); } return MP_OBJ_NEW_SMALL_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(spi_open_obj, 2, spi_open); STATIC mp_obj_t spi_close(size_t n_args, const mp_obj_t *args) { mp_int_t ret = -1; SPI_CHECK_PARAMS(1); SPI_NODE_GET(); ret = aos_hal_spi_finalize(spi_device); if (ret != 0) { LOGE(LOG_TAG, "%s: hal_spi_finalize failed\n", __func__); } py_board_disattach_item(MODULE_SPI, &(driver_obj->spi_handle)); return MP_OBJ_NEW_SMALL_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(spi_close_obj, 1, spi_close); STATIC mp_obj_t spi_read(size_t n_args, const mp_obj_t *args) { mp_int_t ret = -1; SPI_CHECK_PARAMS(2); SPI_NODE_GET(); mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_WRITE); MP_THREAD_GIL_EXIT(); ret = aos_hal_spi_recv(spi_device, bufinfo.buf, bufinfo.len, SPI_TIMEOUT); MP_THREAD_GIL_ENTER(); if (ret < 0) { LOGE(LOG_TAG, "%s: aos_hal_spi_recv failed;\n", __func__); return MP_OBJ_NEW_SMALL_INT(ret); } else { return MP_OBJ_NEW_SMALL_INT(bufinfo.len); } } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(spi_read_obj, 2, spi_read); STATIC mp_obj_t spi_write(size_t n_args, const mp_obj_t *args) { SPI_CHECK_PARAMS(2); SPI_NODE_GET(); mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_READ); MP_THREAD_GIL_EXIT(); mp_int_t ret = aos_hal_spi_send(spi_device, bufinfo.buf, bufinfo.len, SPI_TIMEOUT); MP_THREAD_GIL_ENTER(); if (ret < 0) { LOGE(LOG_TAG, "%s: hal_spi_send failed;\n", __func__); return MP_OBJ_NEW_SMALL_INT(ret); } else { return MP_OBJ_NEW_SMALL_INT(bufinfo.len); } } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(spi_write_obj, 2, spi_write); extern int32_t aos_hal_spi_sends_recvs(spi_dev_t *spi, uint8_t *tx_data, uint32_t tx_size, uint8_t *rx_data, uint32_t rx_size, uint32_t timeout); STATIC mp_obj_t spi_readAfterWrite(size_t n_args, const mp_obj_t *args) { SPI_CHECK_PARAMS(3); SPI_NODE_GET(); mp_buffer_info_t bufinfo_rx; mp_get_buffer_raise(args[1], &bufinfo_rx, MP_BUFFER_WRITE); mp_buffer_info_t bufinfo_tx; mp_get_buffer_raise(args[2], &bufinfo_tx, MP_BUFFER_READ); MP_THREAD_GIL_EXIT(); mp_int_t ret = -1; if (bufinfo_tx.len == 1) { ret = aos_hal_spi_send_recv(spi_device, bufinfo_tx.buf, bufinfo_rx.buf, bufinfo_rx.len, SPI_TIMEOUT); } else { if (bufinfo_tx.len != bufinfo_rx.len) { mp_raise_ValueError(MP_ERROR_TEXT("TX and RX buffer should have same length")); } ret = aos_hal_spi_sends_recvs(spi_device, bufinfo_tx.buf, bufinfo_tx.len, bufinfo_rx.buf, bufinfo_rx.len, SPI_TIMEOUT); } MP_THREAD_GIL_ENTER(); if (ret < 0) { LOGE(LOG_TAG, "aos_hal_spi_send_recv failed\n"); return MP_OBJ_NEW_SMALL_INT(ret); } else { return MP_OBJ_NEW_SMALL_INT(bufinfo_rx.len); } } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(spi_readAfterWrite_obj, 3, spi_readAfterWrite); STATIC mp_obj_t spi_readAndWrite(size_t n_args, const mp_obj_t *args) { SPI_CHECK_PARAMS(3); SPI_NODE_GET(); mp_buffer_info_t read_bufinfo; mp_get_buffer_raise(args[1], &read_bufinfo, MP_BUFFER_WRITE); mp_buffer_info_t write_bufinfo; mp_get_buffer_raise(args[2], &write_bufinfo, MP_BUFFER_READ); MP_THREAD_GIL_EXIT(); mp_int_t ret = aos_hal_spi_send_and_recv(spi_device, write_bufinfo.buf, write_bufinfo.len, read_bufinfo.buf, read_bufinfo.len, SPI_TIMEOUT); MP_THREAD_GIL_ENTER(); if (ret < 0) { LOGE(LOG_TAG, "%s: hal_spi_recv failed;\n", __func__); return MP_OBJ_NEW_SMALL_INT(ret); } else { return MP_OBJ_NEW_SMALL_INT(read_bufinfo.len); } } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(spi_readAndWrite_obj, 3, spi_readAndWrite); STATIC const mp_rom_map_elem_t spi_locals_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_SPI) }, { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&spi_open_obj) }, { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&spi_close_obj) }, { MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&spi_read_obj) }, { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&spi_write_obj) }, { MP_ROM_QSTR(MP_QSTR_readAfterWrite), MP_ROM_PTR(&spi_readAfterWrite_obj) }, { MP_ROM_QSTR(MP_QSTR_readAndWrite), MP_ROM_PTR(&spi_readAndWrite_obj) }, }; STATIC MP_DEFINE_CONST_DICT(spi_locals_dict, spi_locals_dict_table); const mp_obj_type_t driver_spi_type = { .base = { &mp_type_type }, .name = MP_QSTR_SPI, .print = spi_obj_print, .make_new = spi_obj_make_new, .locals_dict = (mp_obj_dict_t *)&spi_locals_dict, };
YifuLiu/AliOS-Things
components/py_engine/modules/driver/spi.c
C
apache-2.0
9,428
/* * This file is part of the MicroPython project, http://micropython.org/ * * Development of the code in this file was sponsored by Microbric Pty Ltd * * The MIT License (MIT) * * Copyright (c) 2013-2015 Damien P. George * Copyright (c) 2016 Paul Sokolovsky * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include <stdio.h> #include <stdlib.h> #include <string.h> // #include <vfsdev/timer_dev.h> #include "aos_hal_timer.h" #include "py/builtin.h" #include "py/gc.h" #include "py/mperrno.h" #include "py/obj.h" #include "py/runtime.h" #include "py/stackctrl.h" #include "ulog/ulog.h" #include "utility.h" #define LOG_TAG "driver_timer" #define TIMER_MODE_ONESHOT (TIMER_RELOAD_MANU) #define TIMER_MODE_PERIODIC (TIMER_RELOAD_AUTO) #define TIMER_DEFAULT_PERIOD (1000000U) typedef struct _driver_timer_obj_t { mp_obj_base_t base; mp_uint_t port; timer_dev_t dev; mp_obj_t callback; } driver_timer_obj_t; const mp_obj_type_t driver_timer_type; STATIC void driver_timer_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { driver_timer_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_printf(print, "port=%d, ", self->port); mp_printf(print, "period=%d, ", self->dev.config.period); mp_printf(print, "reload_mode=%d, ", self->dev.config.reload_mode); } STATIC mp_obj_t driver_timer_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_check_num(n_args, n_kw, 1, 1, false); mp_uint_t port = mp_obj_get_int(args[0]); driver_timer_obj_t *timer_obj = m_new_obj(driver_timer_obj_t); if (!timer_obj) { mp_raise_OSError(MP_EINVAL); return mp_const_none; } memset(timer_obj, 0, sizeof(driver_timer_obj_t)); timer_obj->base.type = &driver_timer_type; timer_obj->port = port; timer_obj->dev.port = port; return MP_OBJ_FROM_PTR(timer_obj); } STATIC void driver_timer_disable(timer_dev_t *tim) { aos_hal_timer_stop(tim); } // STATIC mp_int_t aos_hal_timer_reload(timer_dev_t *tim) // { // int32_t *p_fd = (int32_t *)tim->priv; // return ioctl(*p_fd, IOC_TIMER_RELOAD, (unsigned long)false); // } STATIC void driver_timer_isr(void *self_in) { driver_timer_obj_t *self = (driver_timer_obj_t *)self_in; callback_to_python_LoBo(self->callback, MP_OBJ_FROM_PTR(self), NULL); } STATIC mp_int_t driver_timer_enable(driver_timer_obj_t *self) { mp_int_t ret = -1; timer_dev_t *tim = &self->dev; if (tim != NULL) { ret = aos_hal_timer_init(tim); ret = aos_hal_timer_start(tim); } return ret; } STATIC mp_obj_t driver_timer_init_helper(driver_timer_obj_t *self, mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_period, ARG_mode, ARG_callback, }; static const mp_arg_t allowed_args[] = { { MP_QSTR_period, MP_ARG_KW_ONLY | MP_ARG_INT, { .u_int = TIMER_DEFAULT_PERIOD } }, { MP_QSTR_mode, MP_ARG_KW_ONLY | MP_ARG_INT, { .u_int = TIMER_MODE_PERIODIC } }, { MP_QSTR_callback, MP_ARG_KW_ONLY | MP_ARG_OBJ, { .u_obj = mp_const_none } }, }; driver_timer_disable(&self->dev); mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); if (self == NULL) { LOGE(LOG_TAG, "%s: hal_timer_init failed\n", __func__); return mp_const_none; } self->callback = args[ARG_callback].u_obj; self->dev.port = self->port; self->dev.config.reload_mode = args[ARG_mode].u_int; self->dev.config.period = (mp_uint_t)args[ARG_period].u_int * 1000UL; self->dev.config.arg = self; self->dev.config.cb = driver_timer_isr; mp_int_t ret = driver_timer_enable(self); return MP_OBJ_NEW_SMALL_INT(ret); } STATIC mp_obj_t driver_timer_close(mp_obj_t self_in) { driver_timer_obj_t *self = MP_OBJ_TO_PTR(self_in); timer_dev_t *tim = &self->dev; aos_hal_timer_stop(tim); mp_int_t ret = aos_hal_timer_finalize(tim); return MP_OBJ_NEW_SMALL_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(driver_timer_close_obj, driver_timer_close); STATIC mp_obj_t driver_timer_open(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { return driver_timer_init_helper(args[0], n_args - 1, args + 1, kw_args); } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(driver_timer_open_obj, 1, driver_timer_open); STATIC mp_obj_t driver_timer_period(mp_obj_t self_in, mp_obj_t period) { driver_timer_obj_t *self = self_in; if (self_in == NULL) { mp_raise_OSError(MP_EINVAL); return mp_const_none; } else { self->dev.config.period = mp_obj_get_int(period) * 1000UL; } timer_config_t para = self->dev.config; timer_dev_t *tim = &self->dev; mp_int_t ret = aos_hal_timer_para_chg(tim, para); return MP_OBJ_NEW_SMALL_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_2(driver_timer_period_obj, driver_timer_period); STATIC mp_obj_t driver_timer_start(mp_obj_t self_in) { driver_timer_obj_t *self = self_in; timer_dev_t *tim = &self->dev; mp_int_t ret = aos_hal_timer_start(tim); return MP_OBJ_NEW_SMALL_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(driver_timer_start_obj, driver_timer_start); STATIC mp_obj_t driver_timer_stop(mp_obj_t self_in) { driver_timer_obj_t *self = self_in; timer_dev_t *tim = &self->dev; aos_hal_timer_stop(tim); return MP_OBJ_NEW_SMALL_INT(0); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(driver_timer_stop_obj, driver_timer_stop); STATIC mp_obj_t driver_timer_reload(mp_obj_t self_in) { driver_timer_obj_t *self = self_in; timer_dev_t *tim = &self->dev; mp_int_t ret = aos_hal_timer_reload(tim); return MP_OBJ_NEW_SMALL_INT(0); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(driver_timer_reload_obj, driver_timer_reload); STATIC const mp_rom_map_elem_t driver_timer_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&driver_timer_open_obj) }, { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&driver_timer_close_obj) }, { MP_ROM_QSTR(MP_QSTR_start), MP_ROM_PTR(&driver_timer_start_obj) }, { MP_ROM_QSTR(MP_QSTR_stop), MP_ROM_PTR(&driver_timer_stop_obj) }, { MP_ROM_QSTR(MP_QSTR_period), MP_ROM_PTR(&driver_timer_period_obj) }, { MP_ROM_QSTR(MP_QSTR_reload), MP_ROM_PTR(&driver_timer_reload_obj) }, { MP_ROM_QSTR(MP_QSTR_ONE_SHOT), MP_ROM_INT(TIMER_MODE_ONESHOT) }, { MP_ROM_QSTR(MP_QSTR_PERIODIC), MP_ROM_INT(TIMER_MODE_PERIODIC) }, }; STATIC MP_DEFINE_CONST_DICT(driver_timer_locals_dict, driver_timer_locals_dict_table); const mp_obj_type_t driver_timer_type = { { &mp_type_type }, .name = MP_QSTR_TIMER, .print = driver_timer_print, .make_new = driver_timer_make_new, .locals_dict = (mp_obj_t)&driver_timer_locals_dict, };
YifuLiu/AliOS-Things
components/py_engine/modules/driver/timer.c
C
apache-2.0
7,870
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "aos_hal_uart.h" #include "board_mgr.h" #include "py/builtin.h" #include "py/mperrno.h" #include "py/obj.h" #include "py/runtime.h" #include "ulog/ulog.h" #define LOG_TAG "DRIVER_UART" extern const mp_obj_type_t driver_uart_type; #define UART_TIMEOUT (0xFFFFFF) // this is the actual C-structure for our new object typedef struct { // base represents some basic information, like type mp_obj_base_t Base; // a member created by us char *ModuleName; item_handle_t uart_handle; mp_obj_t callback; } mp_uart_obj_t; void uart_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { LOGD(LOG_TAG, "entern %s;\n", __func__); mp_uart_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_printf(print, "ModuleName(%s)", self->ModuleName); } STATIC mp_obj_t uart_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s;\n", __func__); mp_uart_obj_t *driver_obj = m_new_obj(mp_uart_obj_t); if (!driver_obj) { mp_raise_OSError(MP_EINVAL); } driver_obj->Base.type = &driver_uart_type; driver_obj->ModuleName = "uart"; driver_obj->uart_handle.handle = NULL; return MP_OBJ_FROM_PTR(driver_obj); } STATIC void uart_callback(int uart_num, void *data, uint16_t size, void *udata) { mp_uart_obj_t *driver_obj = (mp_uart_obj_t *)udata; mp_sched_carg_t *carg = make_cargs(MP_SCHED_CTYPE_SINGLE); make_carg_entry(carg, 0, MP_SCHED_ENTRY_TYPE_BYTES, size, data, NULL); callback_to_python_LoBo(driver_obj->callback, mp_const_none, carg); } STATIC mp_obj_t obj_open(size_t n_args, const mp_obj_t *args) { mp_int_t ret = -1; if (n_args < 2) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_uart_obj_t *driver_obj = (mp_uart_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return MP_OBJ_NEW_SMALL_INT(-MP_EINVAL); } const char *id = mp_obj_str_get_str(args[1]); if (id == NULL) { LOGE(LOG_TAG, "%s:illegal par id =%s;\n", __func__, id); return MP_OBJ_NEW_SMALL_INT(-MP_EINVAL); } ret = py_board_mgr_init(); if (ret != 0) { LOGE(LOG_TAG, "%s:py_board_mgr_init failed\n", __func__); return MP_OBJ_NEW_SMALL_INT(-MP_ENOENT); } ret = py_board_attach_item(MODULE_UART, id, &(driver_obj->uart_handle)); if (ret != 0) { LOGE(LOG_TAG, "%s: py_board_attach_item failed ret = %d;\n", __func__, ret); goto out; } uart_dev_t *uart_device = py_board_get_node_by_handle(MODULE_UART, &(driver_obj->uart_handle)); if (NULL == uart_device) { ret = -MP_ENOENT; LOGE(LOG_TAG, "%s: py_board_get_node_by_handle failed;\n", __func__); goto out; } LOGD(LOG_TAG, "%s: port = %d;\n", __func__, uart_device->port); LOGD(LOG_TAG, "%s: baud_rate = %d;\n", __func__, uart_device->config.baud_rate); LOGD(LOG_TAG, "%s: data_width = %d;\n", __func__, uart_device->config.data_width); LOGD(LOG_TAG, "%s: parity = %d;\n", __func__, uart_device->config.parity); LOGD(LOG_TAG, "%s: stop_bits = %d;\n", __func__, uart_device->config.stop_bits); LOGD(LOG_TAG, "%s: flow_control = %d;\n", __func__, uart_device->config.flow_control); LOGD(LOG_TAG, "%s: mode = %d;\n", __func__, uart_device->config.mode); ret = aos_hal_uart_init(uart_device); out: if (0 != ret) { LOGE(LOG_TAG, "%s: aos_hal_uart_init failed ret = %d;\n", __func__, ret); py_board_disattach_item(MODULE_UART, &(driver_obj->uart_handle)); } return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(uart_obj_open, 2, obj_open); STATIC mp_obj_t obj_close(size_t n_args, const mp_obj_t *args) { mp_int_t ret = -1; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_uart_obj_t *driver_obj = (mp_uart_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } uart_dev_t *uart_device = py_board_get_node_by_handle(MODULE_UART, &(driver_obj->uart_handle)); if (NULL == uart_device) { LOGE(LOG_TAG, "%s: py_board_get_node_by_handle failed;\n", __func__); return mp_const_none; } ret = aos_hal_uart_finalize(uart_device); if (ret != 0) { LOGE(LOG_TAG, "aos_hal_uart_finalize failed\n"); } py_board_disattach_item(MODULE_UART, &(driver_obj->uart_handle)); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(uart_obj_close, 1, obj_close); STATIC mp_obj_t obj_read(size_t n_args, const mp_obj_t *args) { uint32_t recvsize = 0; if (n_args != 2) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_uart_obj_t *driver_obj = (mp_uart_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } uart_dev_t *uart_device = py_board_get_node_by_handle(MODULE_UART, &(driver_obj->uart_handle)); if (NULL == uart_device) { LOGE(LOG_TAG, "%s: py_board_get_node_by_handle failed;\n", __func__); return mp_const_none; } mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_WRITE); mp_int_t ret = aos_hal_uart_recv_II(uart_device, bufinfo.buf, bufinfo.len, &recvsize, 0); if (ret == -ETIMEDOUT) { ret = 0; } if (ret != 0) { return MP_ROM_INT(ret); } else { return MP_ROM_INT(recvsize); } } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(uart_obj_read, 2, obj_read); STATIC mp_obj_t obj_write(size_t n_args, const mp_obj_t *args) { mp_int_t ret = -1; if (n_args != 2) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_uart_obj_t *driver_obj = (mp_uart_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } uart_dev_t *uart_device = py_board_get_node_by_handle(MODULE_UART, &(driver_obj->uart_handle)); if (NULL == uart_device) { LOGE(LOG_TAG, "%s: py_board_get_node_by_handle failed;\n", __func__); return mp_const_none; } mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_READ); ret = aos_hal_uart_send(uart_device, bufinfo.buf, bufinfo.len, UART_TIMEOUT); if (ret != 0) { LOGE(LOG_TAG, "aos_hal_uart_send failed\n"); return MP_ROM_INT(ret); } else { return MP_ROM_INT(bufinfo.len); } } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(uart_obj_write, 2, obj_write); STATIC mp_obj_t obj_setBaudRate(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; uart_dev_t *uart_device = NULL; if (n_args < 2) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_uart_obj_t *driver_obj = (mp_uart_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } uart_device = py_board_get_node_by_handle(MODULE_UART, &(driver_obj->uart_handle)); if (NULL == uart_device) { LOGE(LOG_TAG, "%s: py_board_get_node_by_handle failed;\n", __func__); return mp_const_none; } uint32_t baud_rate = (uint32_t)mp_obj_get_int(args[1]); LOGD(LOG_TAG, "%s: set baud_rate = %d;\n", __func__, baud_rate); ret = aos_hal_uart_finalize(uart_device); if (ret != 0) { LOGE(LOG_TAG, "setBaudRate hal_uart_finalize failed\n"); } uart_device->config.baud_rate = baud_rate; LOGD(LOG_TAG, "%s: port = %d;\n", __func__, uart_device->port); LOGD(LOG_TAG, "%s: baud_rate = %d;\n", __func__, uart_device->config.baud_rate); LOGD(LOG_TAG, "%s: data_width = %d;\n", __func__, uart_device->config.data_width); LOGD(LOG_TAG, "%s: parity = %d;\n", __func__, uart_device->config.parity); LOGD(LOG_TAG, "%s: stop_bits = %d;\n", __func__, uart_device->config.stop_bits); LOGD(LOG_TAG, "%s: flow_control = %d;\n", __func__, uart_device->config.flow_control); LOGD(LOG_TAG, "%s: mode = %d;\n", __func__, uart_device->config.mode); ret = aos_hal_uart_init(uart_device); if (ret == -1) { LOGE(LOG_TAG, "setBaudRate hal_uart_init failed\n"); } LOGD(LOG_TAG, "%s:out\n", __func__); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(uart_obj_setBaudRate, 2, obj_setBaudRate); STATIC mp_obj_t uart_any(size_t n_args, const mp_obj_t *args) { uart_dev_t *uart_device = NULL; mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_uart_obj_t *driver_obj = (mp_uart_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } uart_device = py_board_get_node_by_handle(MODULE_UART, &(driver_obj->uart_handle)); if (NULL == uart_device) { LOGE(LOG_TAG, "%s: py_board_get_node_by_handle failed;\n", __func__); return mp_const_none; } return MP_OBJ_NEW_SMALL_INT(aos_hal_uart_any(uart_device)); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(uart_obj_any, 1, uart_any); STATIC mp_obj_t obj_on(size_t n_args, const mp_obj_t *args) { int ret = -1; uart_dev_t *uart_device = NULL; if (n_args < 2) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_uart_obj_t *driver_obj = (mp_uart_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } driver_obj->callback = args[1]; uart_device = py_board_get_node_by_handle(MODULE_UART, &(driver_obj->uart_handle)); if (NULL == uart_device) { LOGE(LOG_TAG, "%s: py_board_get_node_by_handle failed;\n", __func__); return mp_const_none; } ret = aos_hal_uart_callback(uart_device, uart_callback, driver_obj); if (ret < 0) { LOGE(LOG_TAG, "uart_add_recv failed\n"); } return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(uart_obj_on, 2, 3, obj_on); STATIC const mp_rom_map_elem_t uart_locals_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_UART) }, { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&uart_obj_open) }, { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&uart_obj_close) }, { MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&uart_obj_read) }, { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&uart_obj_write) }, { MP_ROM_QSTR(MP_QSTR_any), MP_ROM_PTR(&uart_obj_any) }, { MP_ROM_QSTR(MP_QSTR_on), MP_ROM_PTR(&uart_obj_on) }, }; STATIC MP_DEFINE_CONST_DICT(uart_locals_dict, uart_locals_dict_table); const mp_obj_type_t driver_uart_type = { .base = { &mp_type_type }, .name = MP_QSTR_UART, .print = uart_obj_print, .make_new = uart_obj_make_new, .locals_dict = (mp_obj_dict_t *)&uart_locals_dict, };
YifuLiu/AliOS-Things
components/py_engine/modules/driver/uart.c
C
apache-2.0
11,618
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "py/builtin.h" #include "py/mperrno.h" #include "py/obj.h" #include "py/runtime.h" #include "ulog/ulog.h" #define LOG_TAG "DRIVER_UND" extern const mp_obj_type_t driver_und_type; // this is the actual C-structure for our new object typedef struct { // base represents some basic information, like type mp_obj_base_t Base; // a member created by us char *ModuleName; } mp_und_obj_t; void und_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { LOGD(LOG_TAG, "entern %s;\n", __func__); mp_und_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_printf(print, "ModuleName(%s)", self->ModuleName); } STATIC mp_obj_t und_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s;\n", __func__); mp_und_obj_t *driver_obj = m_new_obj(mp_und_obj_t); if (!driver_obj) { mp_raise_OSError(MP_EINVAL); } driver_obj->Base.type = &driver_und_type; driver_obj->ModuleName = "und"; return MP_OBJ_FROM_PTR(driver_obj); } STATIC mp_obj_t obj_open(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_und_obj_t *driver_obj = (mp_und_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(und_obj_open, 1, obj_open); STATIC mp_obj_t obj_close(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_und_obj_t *driver_obj = (mp_und_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(und_obj_close, 1, obj_close); STATIC mp_obj_t obj_start(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_und_obj_t *driver_obj = (mp_und_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } // ret = und_init(); if (ret != 0) { LOGE(LOG_TAG, "und_init failed\n"); } LOGD(LOG_TAG, "%s:out\n", __func__); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(und_obj_start, 1, obj_start); STATIC mp_obj_t obj_update(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; int32_t cap_idx; int32_t reason_code; if (n_args < 3) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_und_obj_t *driver_obj = (mp_und_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } cap_idx = (uint32_t)mp_obj_get_int(args[1]); reason_code = (uint32_t)mp_obj_get_int(args[2]); LOGD(LOG_TAG, "%s: cap_idx = %d;\n", __func__, cap_idx); LOGD(LOG_TAG, "%s: reason_code = %d;\n", __func__, reason_code); // ret = und_update_statis(cap_idx, reason_code); if (ret != 0) { LOGE(LOG_TAG, "und_update_statis failed\n"); } LOGD(LOG_TAG, "%s:out\n", __func__); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(und_obj_update, 3, obj_update); STATIC mp_obj_t obj_stop(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_und_obj_t *driver_obj = (mp_und_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } // ret = und_deinit(); if (ret != 0) { LOGE(LOG_TAG, "%s:und_deinit failed\n", __func__); } LOGD(LOG_TAG, "%s:out\n", __func__); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(und_obj_stop, 1, obj_stop); STATIC const mp_rom_map_elem_t und_locals_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_UND) }, { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&und_obj_open) }, { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&und_obj_close) }, { MP_ROM_QSTR(MP_QSTR_start), MP_ROM_PTR(&und_obj_start) }, { MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&und_obj_update) }, { MP_ROM_QSTR(MP_QSTR_stop), MP_ROM_PTR(&und_obj_stop) }, }; STATIC MP_DEFINE_CONST_DICT(und_locals_dict, und_locals_dict_table); const mp_obj_type_t driver_und_type = { .base = { &mp_type_type }, .name = MP_QSTR_UND, .print = und_obj_print, .make_new = und_obj_make_new, .locals_dict = (mp_obj_dict_t *)&und_locals_dict, };
YifuLiu/AliOS-Things
components/py_engine/modules/driver/und.c
C
apache-2.0
5,901
/* * Copyright (C) 2015-2021 Alibaba Group Holding Limited */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include "aos_hal_wdg.h" #include "py/builtin.h" #include "py/mperrno.h" #include "py/obj.h" #include "py/runtime.h" #include "ulog/ulog.h" #include "board_mgr.h" #define LOG_TAG "DRIVER_WDT" #define WDT_CHECK_PARAMS(count) \ if (n_args < count) { \ LOGE(LOG_TAG, "%s: args count is illegal: n_args = %d;\n", __func__, n_args); \ return MP_OBJ_NEW_SMALL_INT(-MP_EINVAL); \ } \ mp_wdg_obj_t *driver_obj = (mp_wdg_obj_t *)MP_OBJ_TO_PTR(args[0]); \ do { \ if (driver_obj == NULL) { \ LOGE(LOG_TAG, "driver_obj[WDT] is NULL\n"); \ return MP_OBJ_NEW_SMALL_INT(-MP_EINVAL); \ } \ } while (0) #define WDT_NODE_GET() \ wdg_dev_t *wdt_device = py_board_get_node_by_handle(MODULE_WDT, &(driver_obj->wdg_dev)); \ do { \ if (NULL == wdt_device) { \ LOGE(LOG_TAG, "%s: py_board_get_node_by_handle failed;\n", __func__); \ py_board_disattach_item(MODULE_WDT, &(driver_obj->wdg_dev)); \ return MP_OBJ_NEW_SMALL_INT(-MP_ENXIO); \ } \ } while (0) extern const mp_obj_type_t driver_wdt_type; // this is the actual C-structure for our new object typedef struct { // base represents some basic information, like type mp_obj_base_t Base; // a member created by us char *ModuleName; item_handle_t wdg_dev; } mp_wdg_obj_t; void wdg_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { LOGD(LOG_TAG, "entern %s;\n", __func__); mp_wdg_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_printf(print, "ModuleName(%s)", self->ModuleName); } STATIC mp_obj_t wdg_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s;\n", __func__); mp_wdg_obj_t *driver_obj = m_new_obj(mp_wdg_obj_t); if (!driver_obj) mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("Memory malloc failed")); driver_obj->Base.type = &driver_wdt_type; driver_obj->ModuleName = "wdt"; return MP_OBJ_FROM_PTR(driver_obj); } STATIC mp_obj_t obj_open(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; char *id = NULL; WDT_CHECK_PARAMS(2); if (mp_obj_is_str(args[1])) { id = (char *)mp_obj_str_get_str(args[1]); } else { LOGE(LOG_TAG, "%s: 2nd arg should be string\n", __func__); return MP_OBJ_NEW_SMALL_INT(-MP_EINVAL); } ret = py_board_mgr_init(); if (ret != 0) { LOGE(LOG_TAG, "%s:py_board_mgr_init failed\n", __func__); return MP_OBJ_NEW_SMALL_INT(-MP_ENOENT); } ret = py_board_attach_item(MODULE_WDT, id, &(driver_obj->wdg_dev)); if (ret != 0) { LOGE(LOG_TAG, "%s: py_board_attach_item[%s] failed, ret = %d;\n", __func__, id, ret); goto out; } WDT_NODE_GET(); LOGD(LOG_TAG, "%s: timeout = %d;\n", __func__, wdt_device->config.timeout); ret = aos_hal_wdg_init(wdt_device); out: if (ret != 0) { LOGE(LOG_TAG, "%s: adc open failed ret = %d;\n", __func__, ret); py_board_disattach_item(MODULE_WDT, &(driver_obj->wdg_dev)); } return MP_OBJ_NEW_SMALL_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(wdt_obj_open, 2, obj_open); STATIC mp_obj_t obj_close(size_t n_args, const mp_obj_t *args) { int ret = -1; WDT_CHECK_PARAMS(1); WDT_NODE_GET(); ret = aos_hal_wdg_finalize(wdt_device); py_board_disattach_item(MODULE_WDT, &(driver_obj->wdg_dev)); return MP_OBJ_NEW_SMALL_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(wdt_obj_close, 1, obj_close); STATIC mp_obj_t obj_feed(size_t n_args, const mp_obj_t *args) { WDT_CHECK_PARAMS(1); WDT_NODE_GET(); aos_hal_wdg_reload(wdt_device); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(wdt_obj_feed, 1, obj_feed); STATIC const mp_rom_map_elem_t wdg_locals_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_WDT) }, { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&wdt_obj_open) }, { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&wdt_obj_close) }, { MP_ROM_QSTR(MP_QSTR_feed), MP_ROM_PTR(&wdt_obj_feed) }, }; STATIC MP_DEFINE_CONST_DICT(wdg_locals_dict, wdg_locals_dict_table); const mp_obj_type_t driver_wdt_type = { .base = { &mp_type_type }, .name = MP_QSTR_WDT, .print = wdg_obj_print, .make_new = wdg_obj_make_new, .locals_dict = (mp_obj_dict_t *)&wdg_locals_dict, };
YifuLiu/AliOS-Things
components/py_engine/modules/driver/wdt.c
C
apache-2.0
5,545
#include <stdio.h> #include <stdlib.h> #include <string.h> #if MICROPY_PY_KV #include "aos/kv.h" #include "py/builtin.h" #include "py/mperrno.h" #include "py/obj.h" #include "py/runtime.h" #include "ulog/ulog.h" #define LOG_TAG "KV" #define KV_BUFFER_MAX_LEN 256 STATIC mp_obj_t obj_setStorageSync(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; char *key; char *value; int32_t value_len = 0; if (n_args < 2) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return MP_ROM_INT(-EINVAL); } key = (char *)mp_obj_str_get_str(args[0]); value = (char *)mp_obj_str_get_str(args[1]); value_len = strlen(value); ret = aos_kv_set(key, value, value_len, 1); if (ret != 0) { LOGE(LOG_TAG, "%s:aos_kv_set failed\n", __func__); } LOGD(LOG_TAG, "%s:out\n", __func__); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(kv_obj_setStorageSync, 2, obj_setStorageSync); STATIC mp_obj_t obj_getStorageSync(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; int32_t value_len = KV_BUFFER_MAX_LEN; char *key; char *value; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return MP_ROM_INT(-EINVAL); } key = (char *)mp_obj_str_get_str(args[0]); value = (char *)aos_malloc(KV_BUFFER_MAX_LEN); if (value == NULL) { LOGE(LOG_TAG, "allocate memory failed\n"); return MP_ROM_INT(-ENOMEM); } memset(value, 0, KV_BUFFER_MAX_LEN); ret = aos_kv_get(key, value, &value_len); if (ret != 0) { LOGE(LOG_TAG, "aos_kv_get failed key = %s;\n", key); return MP_ROM_INT(ret); } mp_obj_t val_str = mp_obj_new_str(value, strlen(value)); LOGD(LOG_TAG, "%s:key = %s;value = %s;\n", __func__, key, value); aos_free(value); LOGD(LOG_TAG, "%s:out\n", __func__); return val_str; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(kv_obj_getStorageSync, 1, obj_getStorageSync); STATIC mp_obj_t obj_setiStorageSync(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; char *key; int value; int32_t value_len = 0; if (n_args < 2) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return MP_ROM_INT(-EINVAL); } key = (char *)mp_obj_str_get_str(args[0]); value = (int)mp_obj_get_int(args[1]); value_len = sizeof(value); ret = aos_kv_set(key, &value, value_len, 1); if (ret != 0) { LOGE(LOG_TAG, "%s:aos_kv_set failed\n", __func__); } LOGD(LOG_TAG, "%s:out\n", __func__); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(kv_obj_setiStorageSync, 2, obj_setiStorageSync); STATIC mp_obj_t obj_getiStorageSync(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; int32_t value_len = KV_BUFFER_MAX_LEN; char *key; int value; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return MP_ROM_INT(-EINVAL); } key = (char *)mp_obj_str_get_str(args[0]); ret = aos_kv_get(key, &value, &value_len); if (ret != 0) { LOGE(LOG_TAG, "aos_kv_get failed key = %s;\n", key); return MP_ROM_INT(ret); } return mp_obj_new_int(value); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(kv_obj_getiStorageSync, 1, obj_getiStorageSync); STATIC mp_obj_t obj_removeStorageSync(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; char *key; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return MP_ROM_INT(-EINVAL); } key = (char *)mp_obj_str_get_str(args[0]); LOGD(LOG_TAG, "%s:key = %s;\n", __func__, key); ret = aos_kv_del(key); if (ret != 0) { LOGE(LOG_TAG, "kv delete item failed\n"); return MP_ROM_INT(ret); } LOGD(LOG_TAG, "%s:out\n", __func__); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(kv_obj_removeStorageSync, 1, obj_removeStorageSync); STATIC const mp_rom_map_elem_t kv_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_kv) }, { MP_ROM_QSTR(MP_QSTR_set), MP_ROM_PTR(&kv_obj_setStorageSync) }, { MP_ROM_QSTR(MP_QSTR_get), MP_ROM_PTR(&kv_obj_getStorageSync) }, { MP_ROM_QSTR(MP_QSTR_seti), MP_ROM_PTR(&kv_obj_setiStorageSync) }, { MP_ROM_QSTR(MP_QSTR_geti), MP_ROM_PTR(&kv_obj_getiStorageSync) }, { MP_ROM_QSTR(MP_QSTR_remove), MP_ROM_PTR(&kv_obj_removeStorageSync) }, }; STATIC MP_DEFINE_CONST_DICT(kv_module_globals, kv_module_globals_table); const mp_obj_module_t mp_module_kv = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&kv_module_globals, }; MP_REGISTER_MODULE(MP_QSTR_kv, mp_module_kv, MICROPY_PY_KV); #endif // MICROPY_PY_KV
YifuLiu/AliOS-Things
components/py_engine/modules/kv/modkv.c
C
apache-2.0
5,174
#c interface #add include file set(CINTERFACEDIR ${MPYADAPTORDIR}/component/minicv/base/modules/c) set(CORE ${MPYADAPTORDIR}/component/minicv/base/modules/core) set(MLDIR ${MPYADAPTORDIR}/component/minicv/base/modules/ml) include_directories(${MPYADAPTORDIR}/component/minicv/base/include) include_directories(${MPYADAPTORDIR}/component/minicv/base/include/base) include(${CINTERFACEDIR}/cv.mk) include(${CORE}/cv.mk) if(${PY_BUILD_AI}) include(${MLDIR}/cv.mk) endif() #add src file
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/cv.mk
Makefile
apache-2.0
487
/* * Copyright (C) 2015-2020 Alibaba Group Holding Limited */ #ifndef IHAAS_DATA_INPUT_H #define IHAAS_DATA_INPUT_H #include "base/include/base/HaasDataInputDef.h" /** * @brief All Data input Class * @author HaasAI Group */ class IHaasDataInput { public: virtual ~IHaasDataInput(){} /** * @brief Open the dataSouce * @param[in] filename : The Name of DataSource * @note Notice that the filename is the full path. * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * IHaasDataInput * mDataInput = NULL; * mDataInput = IHaasDataInputInstance(); * char* filename = "/data/HaasAI/testvideo.jpg" * res_ res = 0; * res = mDataInput->Open(filename); * @endcode */ virtual int Open(char *filename) = 0; /** * @brief Open the Camera * @param[in] cameraNum : the number of Camera * @note Notice that 0 = Front Camera;1 = Back Camera. * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * IHaasDataInput * mDataInput = NULL; * mDataInput = IHaasDataInputInstance(); * int cameraindex = 0 * res_ res = 0; * res = mDataInput->Open(cameraindex); * @endcode */ virtual int Open(int cameraNum) = 0; /** * @brief Close the Camera * @note NULL * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * IHaasDataInput * mDataInput = NULL; * mDataInput = IHaasDataInputInstance(); * res_ res = 0; * res = mDataInput->Close(); * @endcode */ virtual int Close() = 0; /** * @brief Check the data Ready state * @note NULL * @return * 0 Ready \n * -1 Not Ready \n * @par Sample * @code * IHaasDataInput * mDataInput = NULL; * mDataInput = IHaasDataInputInstance(); * bool res = false; * res = mDataInput->CheckDataReady(); * @endcode */ virtual bool CheckDataReady() = 0; /** * @brief Request Source Data * @param[in] image : image Struct include data information * @param[in] timeout : set the timoutout value * @note NULL * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * ImageBuffer_t *image = NULL; * IHaasDataInput * mDataInput = NULL; * mDataInput = IHaasDataInputInstance(); * res_ res = 0; * res = mDataInput->RequestData(&image, 1000); * @endcode */ virtual int RequestData(ImageBuffer_t** image, int32_t timeout) = 0; /** * @brief Release Source Data * @param[in] image : image Struct include data information * @note NULL * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * IHaasDataInput * mDataInput = NULL; * mDataInput = IHaasDataInputInstance(); * res_ res = 0; * res = mDataInput->ReleaseData(image, 1000); * @endcode */ virtual int ReleaseData(ImageBuffer_t* image) = 0; }; extern "C" { /** * @brief Get HaasDataInput Instance * @note NULL * @return * !0 successfully \n * NULL failed \n * @par Sample * @code * IHaasDataInput * mDataInput = NULL; * mDataInput = IHaasDataInputInstance(); * @endcode */ IHaasDataInput* IHaasDataInputInstance(DataInputType_t type); } #endif
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/include/IHaasDataInput.h
C++
apache-2.0
3,130
/* * Copyright (C) 2020-2021 Alibaba Group Holding Limited */ #ifndef IHAAS_IMAGE_CODEC_H #define IHAAS_IMAGE_CODEC_H #include "base/include/base/HaasCommonImage.h" #include "base/include/base/HaasImageCodecDef.h" /** * @brief image Codec class * @author HaasAI Group */ class IHaasImageCodec { public: virtual ~IHaasImageCodec(){} /** * @brief Read A Image from Path * @param[out] image : store the image infomation * @param[in] filename : the path of image * @note filename is the image full path. * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * IHaasImageCodec * mIHaasImageCodec = NULL; * ImageBuffer_t image; * char* path = "/data/HaasAI/test.jpg"; * mIHaasImageCodec = IHaasImageCodecInstance(); * int res = 0; * res = mIHaasImageCodec->ImgRead(&image, path.c_str()); * @endcode */ virtual int ImgRead(ImageBuffer_t **image, char * filename) = 0; /** * @brief Read Multi Image from Path * @param[out] images : store the images infomation * @param[in] filename : the path of image * @note filename is the image full path. * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * IHaasImageCodec * mIHaasImageCodec = NULL; * ImageBuffer_t *image = NULL; * char* path = "/data/HaasAI"; * mIHaasImageCodec = IHaasImageCodecInstance(); * int res = 0; * res = mIHaasImageCodec->ImgReadMulti(&image, path.c_str()); * @endcode */ virtual int ImgReadMulti(ImageBuffer_t **images, char * filename) = 0; /** * @brief ImageBuffer_t A Image to Path * @param[in] image : store the image infomation * @param[in] filename : the path of image * @note filename is the image full path. * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * IHaasImageCodec * mIHaasImageCodec = NULL; * ImageBuffer_t *image = xx; * char* path = "/data/HaasAI/test.jpg"; * mIHaasImageCodec = IHaasImageCodecInstance(); * int res = 0; * res = mIHaasImageCodec->ImgWrite(image, path.c_str()); * @endcode */ virtual int ImgWrite(ImageBuffer_t *image, char * filename) = 0; /** * @brief Write Images to Path * @param[in] image : store the image infomation * @param[in] filename : the path of image * @note filename is the image full path. * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * IHaasImageCodec * mIHaasImageCodec = NULL; * ImageBuffer_t **image = xx; * char* path = "/data/HaasAI"; * mIHaasImageCodec = IHaasImageCodecInstance(); * int res = 0; * res = mIHaasImageCodec->ImgWriteMulti(image, path.c_str()); * @endcode */ virtual int ImgWriteMulti(ImageBuffer_t **images, char * filename) = 0; /** * @brief Decode image pixels to image Struct * @param[in] addr : image pixels address * @param[out] image : store the image infomation * @note filename is the image full path. * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * IHaasImageCodec * mIHaasImageCodec = NULL; * ImageBuffer_t image; * void *addr = xx; * mIHaasImageCodec = IHaasImageCodecInstance(); * int res = 0; * res = mIHaasImageCodec->ImgWriteMulti(addr, &image); * @endcode */ virtual int ImgDecode(void *addr, ImageBuffer_t **image) = 0; /** * @brief Decode image to image Struct * @param[in] filename : image path * @note filename is the image full path. * @return * !0 successfully \n * NULL failed \n * @par Sample * @code * IHaasImageCodec * mIHaasImageCodec = NULL; * char* path = "/data/HaasAI/test.jpg"; * ImageBuffer_t *image = NULL; * mIHaasImageCodec = IHaasImageCodecInstance(); * image = mIHaasImageCodec->ImgWriteMulti(path.c_str()); * @endcode */ virtual ImageBuffer_t * ImgDecode(const char * filename) = 0; /** * @brief Encode image to image Struct * @param[in] addr : image pixels address * @param[out] filename : image path * @note filename is the image full path. * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * IHaasImageCodec * mIHaasImageCodec = NULL; * ImageBuffer_t image; * void *addr = NULL; * mIHaasImageCodec = IHaasImageCodecInstance(); * image = mIHaasImageCodec->ImgEncode(addr, &image); * @endcode */ virtual int ImgEncode(void *addr, ImageBuffer_t ** image) = 0; /** * @brief check if has the encoder * @param[in] filename : image path * @note filename is the image full path. * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * IHaasImageCodec * mIHaasImageCodec = NULL; * mIHaasImageCodec = IHaasImageCodecInstance(); * char* path = "/data/HaasAI/test.jpg"; * int res = -1; * res = mIHaasImageCodec->haveImageReader(path.c_str()); * @endcode */ virtual int haveImageReader(char * filename) = 0; /** * @brief check if has the decoder * @param[in] filename : image path * @note filename is the image full path. * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * IHaasImageCodec * mIHaasImageCodec = NULL; * mIHaasImageCodec = IHaasImageCodecInstance(); * char* path = "/data/HaasAI/test.jpg"; * int res = -1; * res = mIHaasImageCodec->haveImageWriter(path.c_str()); * @endcode */ virtual int haveImageWriter(char * filename) = 0; }; extern "C" { /** * @brief Get HaasImageCodec Instance * @param[in] type : CodecImageType_t * @note * @return * !0 Open successfully \n * NULL Open failed \n * @par Sample * @code * IHaasImageCodec * mHaasImageCodec = NULL; * mHaasImageCodec = IHaasImageCodecInstance(); * @endcode */ IHaasImageCodec* IHaasImageCodecInstance(CodecImageType_t type); } #endif
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/include/IHaasImageCodec.h
C++
apache-2.0
5,815
/* * Copyright (C) 2020-2021 Alibaba Group Holding Limited */ #ifndef IHAAS_IMAGE_PROC_H #define IHAAS_IMAGE_PROC_H #include "base/include/base/HaasCommonImage.h" #include "base/include/base/HaasImageProcDef.h" /** * @brief image Proc class * @author HaasAI Group */ class IHaasImageProc { public: virtual ~IHaasImageProc(){} /** * @brief Open image proc module * @note * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * IHaasImageProc * mIHaasImageProc = NULL; * mIHaasImageProc = IHaasImageProcInstance(); * int res = 0; * res = mIHaasImageProc->Open(); * @endcode */ virtual int Open() = 0; /** * @brief Close image proc module * @note * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * IHaasImageProc * mIHaasImageProc = NULL; * mIHaasImageProc = IHaasImageProcInstance(); * int res = 0; * res = mIHaasImageProc->Close(); * @endcode */ virtual int Close() = 0; /** * @brief convert the image format * @param[in] src : source image * @param[in] format : dest format * @param[out] dst : dest image info * @note * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * ImageBuffer_t *src = xxx; * ImageBuffer_t *dst = NULL; * PixelFmt_t format = xxx; * IHaasImageProc * mIHaasImageProc = NULL; * mIHaasImageProc = IHaasImageProcInstance(); * int res = 0; * res = mIHaasImageProc->CvtColor(src, format, &dst); * @endcode */ virtual int CvtColor(const ImageBuffer_t* src, PixelFmt_t dst_format, ImageBuffer_t** dst) = 0; /** * @brief resize the image size * @param[in] src : source image * @param[in] dst_size : dest size * @param[out] dst : dest image info * @note * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * ImageBuffer_t *src = xxx; * ImageBuffer_t *dst = NULL; * ImageSize_t size = xxx; * IHaasImageProc * mIHaasImageProc = NULL; * mIHaasImageProc = IHaasImageProcInstance(); * int res = 0; * res = mIHaasImageProc->Resize(src, size, &dst); * @endcode */ virtual int Resize(const ImageBuffer_t* src, const ImageSize_t dst_size, ImageBuffer_t** dst) = 0; /** * @brief copy the src img to tartge img * @param[in] src : source image * @param[out] dst : dest image info * @note * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * ImageBuffer_t *src = xxx; * ImageBuffer_t *dst = NULL; * IHaasImageProc * mIHaasImageProc = NULL; * mIHaasImageProc = IHaasImageProcInstance(); * int res = 0; * res = mIHaasImageProc->ImgCopy(src, &dst); * @endcode */ virtual int ImgCopy(const ImageBuffer_t* src, ImageBuffer_t** dst) = 0; /** * @brief draw a rectangle on tartge img * @param[in] src : source image * @param[in] left : rect left * @param[in] top : rect top * @param[in] right : rect right * @param[in] bottom : rect bottom * @note * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * ImageBuffer_t *src = xxx; * IHaasImageProc * mIHaasImageProc = NULL; * mIHaasImageProc = IHaasImageProcInstance(); * int res = 0; * int32_t left = 10; * int32_t top = 20; * int32_t right = 50; * int32_t bottom = 100; * res = mIHaasImageProc->Rectangle(src, left, top, right, bottom); * @endcode */ virtual int Rectangle(const ImageBuffer_t* src, int32_t left, int32_t top, int32_t right, int32_t bottom) = 0; /** * @brief draw a circle on tartge img * @param[in] src : source image * @param[in] center_x : circle center point x * @param[in] center_y : circle center point r * @param[in] radius : circle radius * @note * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * ImageBuffer_t *src = xxx; * IHaasImageProc * mIHaasImageProc = NULL; * mIHaasImageProc = IHaasImageProcInstance(); * int res = 0; * int32_t center_x = 10; * int32_t center_y = 20; * int32_t radius = 50; * res = mIHaasImageProc->Circle(src, center_x, center_y, radius); * @endcode */ virtual int Circle(const ImageBuffer_t* src, int32_t center_x, int32_t center_y, int32_t radius) = 0; /** * @brief draw a marker on tartge img * @param[in] src : source image * @param[in] pt : position of point * @param[in] type : Marker type * @note * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * ImageBuffer_t *src = xxx; * IHaasImageProc * mIHaasImageProc = NULL; * mIHaasImageProc = IHaasImageProcInstance(); * int res = 0; * Point_t point; * point.x = 10; * point.y = 20; * int32_t type = xx; * res = mIHaasImageProc->DrawMarker(src, &point, type); * @endcode */ virtual int DrawMarker(const ImageBuffer_t* src, Point_t *pt, int32_t type) = 0; /** * @brief Fill polly at target point * @param[in] src : source image * @param[in] pt : position of point * @param[in] color : fill use color * @note * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * ImageBuffer_t *src = xxx; * IHaasImageProc * mIHaasImageProc = NULL; * mIHaasImageProc = IHaasImageProcInstance(); * int res = 0; * Point_t point; * point.x = 10; * point.y = 20; * int32_t color = xx; * res = mIHaasImageProc->FillPoly(src, &point, color); * @endcode */ virtual int FillPoly(const ImageBuffer_t* src, Point_t** pts, int32_t color) = 0; /** * @brief Put Text at target image * @param[in] src : source image * @param[in] text : char* * @param[in] left : text left position * @param[in] top : text top position * @note * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * ImageBuffer_t *src = xxx; * IHaasImageProc * mIHaasImageProc = NULL; * mIHaasImageProc = IHaasImageProcInstance(); * int res = 0; * char* text = "for test" * int32_t left = 10; * int32_t top = 20; * res = mIHaasImageProc->PutText(src, text, left, top); * @endcode */ virtual int PutText(const ImageBuffer_t* src, char* text, int32_t left, int32_t top) = 0; /** * @brief Dilate Erode at target image * @param[in] src : source image * @param[out] dst : dst image * @param[in] imode : set mode * @param[in] iThresh : set iThresh * @note * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * ImageBuffer_t *src = xxx; * ImageBuffer_t dst; * IHaasImageProc * mIHaasImageProc = NULL; * mIHaasImageProc = IHaasImageProcInstance(); * int res = 0; * int32_t iMode = xx; * int32_t iThresh = xx; * res = mIHaasImageProc->DilateErode(src, &dst, iMode, iThresh); * @endcode */ virtual int DilateErode(const ImageBuffer_t* src, ImageBuffer_t* dst, int32_t iMode, int32_t iThresh) = 0; /** * @brief Add two image to target image * @param[in] src : source image * @param[in] added : added image * @param[out] dst : dst image * @note * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * ImageBuffer_t *src = xxx; * ImageBuffer_t *added = yyy; * ImageBuffer_t dst; * IHaasImageProc * mIHaasImageProc = NULL; * mIHaasImageProc = IHaasImageProcInstance(); * int res = 0; * res = mIHaasImageProc->ImageAdd(src, added, &dst); * @endcode */ virtual void ImageAdd(const ImageBuffer_t* src, ImageBuffer_t* added, ImageBuffer_t* dst) = 0; /** * @brief Minus two image to target image * @param[in] src : source image * @param[in] minused : minused image * @param[out] dst : dst image * @note * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * ImageBuffer_t *src = xxx; * ImageBuffer_t *minused = yyy; * ImageBuffer_t dst; * IHaasImageProc * mIHaasImageProc = NULL; * mIHaasImageProc = IHaasImageProcInstance(); * int res = 0; * res = mIHaasImageProc->ImageMinus(src, minused, &dst); * @endcode */ virtual void ImageMinus(const ImageBuffer_t* src, ImageBuffer_t* minused, ImageBuffer_t* dst) = 0; /** * @brief multiply two image to target image * @param[in] src : source image * @param[in] multiplied : added image * @param[out] dst : dst image * @note * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * ImageBuffer_t *src = xxx; * ImageBuffer_t *multiplied = yyy; * ImageBuffer_t dst; * IHaasImageProc * mIHaasImageProc = NULL; * mIHaasImageProc = IHaasImageProcInstance(); * int res = 0; * res = mIHaasImageProc->ImageAdd(src, multiplied, &dst); * @endcode */ virtual void ImageElementMultiply(const ImageBuffer_t* src, ImageBuffer_t* multiplied, ImageBuffer_t* dst) = 0; /** * @brief divie two image to target image * @param[in] src : source image * @param[in] divied : added image * @param[out] dst : dst image * @note * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * ImageBuffer_t *src = xxx; * ImageBuffer_t *divied = yyy; * ImageBuffer_t dst; * IHaasImageProc * mIHaasImageProc = NULL; * mIHaasImageProc = IHaasImageProcInstance(); * int res = 0; * res = mIHaasImageProc->ImageElementDivide(src, divied, &dst); * @endcode */ virtual void ImageElementDivide(const ImageBuffer_t* src, ImageBuffer_t* divied, ImageBuffer_t* dst) = 0; /** * @brief write source image to image file * @param[in] src : source image * @param[in] file_name : image store path * @note * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * ImageBuffer_t *src = xxx; * ImageBuffer_t dst; * IHaasImageProc * mIHaasImageProc = NULL; * mIHaasImageProc = IHaasImageProcInstance(); * int res = 0; * std:string path = "/data/HaasAI/test.jpg"; * res = mIHaasImageProc->ImageAdd(src, path.c_str()); * @endcode */ virtual int WriteImageToFile(const ImageBuffer_t* src, char* file_name) = 0; }; extern "C" { /** * @brief Get HaasImageProc Instance * @param[in] type : ImageProcType_t * @note * @return * !0 Open successfully \n * NULL Open failed \n * @par Sample * @code * IHaasImageProc * mHaasImageProc = NULL; * mHaasImageProc = IHaasImageProcInstance(type); * @endcode */ IHaasImageProc* IHaasImageProcInstance(ImageProcType_t type); } #endif
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/include/IHaasImageProc.h
C++
apache-2.0
10,765
/* * Copyright (C) 2020-2021 Alibaba Group Holding Limited */ #ifndef IHAAS_ML_H #define IHAAS_ML_H #include "base/include/base/HaasCommonImage.h" #include "base/include/base/HaasMLDef.h" /** * @brief Machine Learning Control Class * @author HaasAI Group */ class IHaasML { public: virtual ~IHaasML() {} /** * @brief config http info(for ucloud AI) * @param[in] key : OSS Access Key * @param[in] secret : OSS Access secret * @param[in] endpoint : The region id * @param[in] bucket : OSS endpoint * @note. * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * IHaasML * mIHaasML = NULL; * mIHaasML = IHaasMLInstance(); * res_ res = 0; * res = mIHaasML->Config(NULL,NULL,NULL,NULL,NULL); * @endcode */ virtual int Config(char *key, char *secret, char *endpoint, char *bucket) { return 0; } /** * @brief set input data(come frome HaasDataInput) * @param[in] dataPath : The path of DataSource * @note Notice that the dataPath is the full path. * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * IHaasML * mIHaasML = NULL; * mIHaasML = IHaasMLInstance(); * char* dataPath = "/data/HaasAI/xxx" * res_ res = 0; * res = mIHaasML->SetInputData(dataPath.c_str()); * @endcode */ virtual int SetInputData(const char *dataPath, const char *compareDataPath) = 0; /** * @brief Load AI mode object * @param[in] modePath : The path of AI Mode * @note Notice that the modePath is the full path. * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * IHaasML * mIHaasML = NULL; * mIHaasML = IHaasMLInstance(); * char* modePath = "/data/HaasAI/aimode" * res_ res = 0; * res = mIHaasML->LoadNet(modePath.c_str()); * @endcode */ virtual int LoadNet(const char* modePath) = 0; /** * @brief Start AI Predict * @note * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * IHaasML * mIHaasML = NULL; * mIHaasML = IHaasMLInstance(); * res_ res = 0; * res = mIHaasML->Predict(); * @endcode */ virtual int Predict() = 0; /** * @brief Get AI Predict Result * @param[out] outResult : The result of Predict * @param[int] len : The len of readBuffer * @note * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * IHaasML * mIHaasML = NULL; * mIHaasML = IHaasMLInstance(); * int res = 0; * char *outResult = NULL; * int len; * res = mIHaasML->GetPredictResponses(&outResult, &len); * @endcode */ virtual int GetPredictResponses(char* outResult, int len) = 0; /** * @brief un load AI Predict mode obj * @note * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * IHaasML * mIHaasML = NULL; * mIHaasML = IHaasMLInstance(); * res_ res = 0; * res = mIHaasML->UnLoadNet(); * @endcode */ virtual int UnLoadNet() = 0; }; extern "C" { /** * @brief Get HaasML Instance * @note NULL * @return * !0 successfully \n * NULL failed \n * @par Sample * @code * IHaasML * mHaasML = NULL; * mHaasML = IHaasMLInstance(); * @endcode */ IHaasML* IHaasMLInstance(MLEngineType_t type); } #endif
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/include/IHaasML.h
C++
apache-2.0
4,037
/* * Copyright (C) 2020-2021 Alibaba Group Holding Limited */ #ifndef IHAAS_UI_H #define IHAAS_UI_H #include "string.h" #include "base/include/base/HaasCommonImage.h" #include "base/include/base/HaasUIDef.h" /** * @brief Haas UI Control Class * @author HaasAI Group */ class IHaasUI { public: virtual ~IHaasUI(){} /** * @brief Get display device width * @note * @return * !0 successfully \n * -1 failed \n * @par Sample * @code * IHaasUI * mHaasUI = NULL; * mHaasUI = IHaasUIInstance(); * res_ res = 0; * res = mHaasUI->GetDisplayWidth(); * @endcode */ virtual int GetDisplayWidth() = 0; /** * @brief Get display device height * @note * @return * !0 successfully \n * -1 failed \n * @par Sample * @code * IHaasUI * mHaasUI = NULL; * mHaasUI = IHaasUIInstance(); * res_ res = 0; * res = mHaasUI->GetDisplayHeight(); * @endcode */ virtual int GetDisplayHeight() = 0; /** * @brief Get display device backlight value * @note * @return * !0 successfully \n * -1 failed \n * @par Sample * @code * IHaasUI * mHaasUI = NULL; * mHaasUI = IHaasUIInstance(); * res_ res = 0; * res = mHaasUI->GetDisplayBacklight(); * @endcode */ virtual int GetDisplayBacklight() = 0; /** * @brief Set display device backlight value * @param[in] value:backlight value * @note * @return * !0 successfully \n * -1 failed \n * @par Sample * @code * IHaasUI * mHaasUI = NULL; * mHaasUI = IHaasUIInstance(); * int res = 0; * int32_t value = xx; * res = mHaasUI->SetDisplayBacklight(value); * @endcode */ virtual int SetDisplayBacklight(int32_t value) = 0; /** * @brief Get display device type * @note * @return * !0 successfully \n * -1 failed \n * @par Sample * @code * IHaasUI * mHaasUI = NULL; * mHaasUI = IHaasUIInstance(); * res_ res = 0; * res = mHaasUI->GetDisplayType(); * @endcode */ virtual int GetDisplayType() = 0; /** * @brief Get display device freq * @note * @return * !0 successfully \n * -1 failed \n * @par Sample * @code * IHaasUI * mHaasUI = NULL; * mHaasUI = IHaasUIInstance(); * res_ res = 0; * res = mHaasUI->GetDisplayFreq(); * @endcode */ virtual int GetDisplayFreq() = 0; /** * @brief Set display device freq * @param[in] freq:display device freq * @note * @return * !0 successfully \n * -1 failed \n * @par Sample * @code * IHaasUI * mHaasUI = NULL; * mHaasUI = IHaasUIInstance(); * int res = 0; * int32_t freq = xx; * res = mHaasUI->SetDisplayFreq(freq); * @endcode */ virtual int SetDisplayFreq(int32_t freq) = 0; /** * @brief Draw a point on screen * @param[in] pt: the point position * @param[in] color: point color * @note * @return * !0 successfully \n * -1 failed \n * @par Sample * @code * IHaasUI * mHaasUI = NULL; * mHaasUI = IHaasUIInstance(); * int res = 0; * Point_t point; * point.x = 10; * point.y = 20; * int32_t color = xx; * res = mHaasUI->DrawPoint(&point, color); * @endcode */ virtual int DrawPoint(Point_t *pt, int32_t color) = 0; /** * @brief Draw a line on screen * @param[in] start: start point position * @param[in] end: stop point position * @param[in] color: point color * @note * @return * !0 successfully \n * -1 failed \n * @par Sample * @code * IHaasUI * mHaasUI = NULL; * mHaasUI = IHaasUIInstance(); * int res = 0; * Point_t start; * start.x = 10; * start.y = 20; * Point_t end; * end.x = 10; * end.y = 20; * int32_t color = xx; * res = mHaasUI->DrawLine(&start, &end, color); * @endcode */ virtual int DrawLine(Point_t *start, Point_t *end, int32_t color) = 0; /** * @brief Draw a Rectangle on screen * @param[in] left: Rectangle left * @param[in] top: Rectangle top * @param[in] right: Rectangle right * @param[in] bottom: Rectangle bottom * @param[in] color: point color * @note * @return * !0 successfully \n * -1 failed \n * @par Sample * @code * IHaasUI * mHaasUI = NULL; * mHaasUI = IHaasUIInstance(); * int res = 0; * int32_t left = 10; * int32_t top = 10; * int32_t right = 50; * int32_t bottom = 100; * int32_t color = xx; * res = mHaasUI->DrawRectangle(left, top, right, bottom, color); * @endcode */ virtual int DrawRectangle(int32_t left, int32_t top, int32_t right, int32_t bottom, int32_t color) = 0; /** * @brief Draw a circle on screen * @param[in] center: circle point * @param[in] radius: circle radius * @param[in] color: point color * @note * @return * !0 successfully \n * -1 failed \n * @par Sample * @code * IHaasUI * mHaasUI = NULL; * mHaasUI = IHaasUIInstance(); * int res = 0; * Point_t point; * point.x = 10; * point.y = 50; * int32_t radius = 100; * int32_t color = xx; * res = mHaasUI->DrawCircle(&point, radius, color); * @endcode */ virtual int DrawCircle(Point_t * center, int32_t radius, int32_t color) = 0; /** * @brief Draw a String on screen * @param[in] text: String value * @param[in] size: String size * @param[in] color: point color * @param[in] left: Rectangle left * @param[in] top: Rectangle top * @param[in] right: Rectangle right * @param[in] bottom: Rectangle bottom * @note * @return * !0 successfully \n * -1 failed \n * @par Sample * @code * IHaasUI * mHaasUI = NULL; * mHaasUI = IHaasUIInstance(); * char* text = "for test" * int32_t size = 10; * int32_t color = xx; * int res = 0; * int32_t left = 10; * int32_t top = 10; * int32_t right = 50; * int32_t bottom = 100; * res = mHaasUI->DrawText(text, size, color, left, top, right, bottom); * @endcode */ virtual void DrawText(char* text, int32_t size, int32_t color, int32_t left, int32_t top, int32_t right, int32_t bottom) = 0; /** * @brief Draw Pixel on screen * @param[in] pixles: data address * @param[in] pt: pixles draw position * @param[in] width: draw width * @param[in] height: draw height * @note * @return * !0 successfully \n * -1 failed \n * @par Sample * @code * IHaasUI * mHaasUI = NULL; * mHaasUI = IHaasUIInstance(); * int res = 0; * int32_t* pixels = address; * Point_t point; * point.x = 10; * point.y = 50; * int32_t width = 100; * int32_t height = 200; * res = mHaasUI->DrawCircle(pixels, &point, width, heigt); * @endcode */ virtual bool DrawPixels(int32_t* pixels, Point_t *pt, int32_t width, int32_t height) = 0; /** * @brief Draw a image on screen * @param[in] path: image path * @param[in] pt: pixles draw position * @param[in] width: draw width * @param[in] height: draw height * @note * @return * !0 successfully \n * -1 failed \n * @par Sample * @code * IHaasUI * mHaasUI = NULL; * mHaasUI = IHaasUIInstance(); * int res = 0; * char* path = "/data/HaasAI/test.jpg"; * Point_t point; * point.x = 10; * point.y = 50; * int32_t width = 100; * int32_t height = 200; * res = mHaasUI->DrawCircle(path, &point, width, heigt); * @endcode */ virtual bool DrawImage(char * path, Point_t *pt, int32_t width, int32_t height) = 0; /** * @brief update Displat Content * @note * @return * always successfully \n * @par Sample * @code * IHaasUI * mHaasUI = NULL; * mHaasUI = IHaasUIInstance(); * res_ res = 0; * res = mHaasUI->UpdateDisplay(); * @endcode */ virtual void UpdateDisplay() = 0; }; extern "C" { /** * @brief Get HaasUI Instance * @param[in] type: UIFrameworkType_t * @note NULL * @return * !0 successfully \n * NULL failed \n * @par Sample * @code * IHaasUI * mHaasUI = NULL; * mHaasUI = IHaasUIInstance(); * @endcode */ IHaasUI* IHaasUIInstance(UIFrameworkType_t type); } #endif
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/include/IHaasUI.h
C++
apache-2.0
8,230
/* * Copyright (C) 2020-2021 Alibaba Group Holding Limited */ #ifndef IHAAS_VIDEO_CODEC_H #define IHAAS_VIDEO_CODEC_H #include "base/modules/core/include/HaasErrno.h" #include "base/include/base/HaasCommonVideo.h" #include "base/include/base/HaasCommonImage.h" #include "base/include/base/HaasVideoCodecDef.h" /** * @brief Video Codec Control Class * @author HaasAI Group */ class IHaasVideoCodec { public: virtual ~IHaasVideoCodec(){} /** * @brief Open the video codec module * @note * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * IHaasVideoCodec * mHaasVideoCodec = NULL; * mHaasVideoCodec = HaasVideoCodecInstance(); * res_ res = 0; * res = mHaasVideoCodec->Open(); * @endcode */ virtual int Open() = 0; /** * @brief Close the video codec module * @note * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * IHaasVideoCodec * mHaasVideoCodec = NULL; * mHaasVideoCodec = HaasVideoCodecInstance(); * res_ res = 0; * res = mHaasVideoCodec->Close(); * @endcode */ virtual int Close() = 0; /** * @brief set Video decoder config information * @param[in] config: obtain video decoder information * @note * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * IHaasVideoCodec * mHaasVideoCodec = NULL; * mHaasVideoCodec = HaasVideoCodecInstance(); * DecodeConfig_t *config = xx; * res_ res = 0; * res = mHaasVideoCodec->DecodeConfig(config); * @endcode */ virtual int DecodeConfig(DecodeConfig_t* config) = 0; /** * @brief start video codec * @note * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * IHaasVideoCodec * mHaasVideoCodec = NULL; * mHaasVideoCodec = HaasVideoCodecInstance(); * res_ res = 0; * res = mHaasVideoCodec->StartDecode(); * @endcode */ virtual int StartDecode() = 0; /** * @brief stop video codec * @note * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * IHaasVideoCodec * mHaasVideoCodec = NULL; * mHaasVideoCodec = HaasVideoCodecInstance(); * res_ res = 0; * res = mHaasVideoCodec->StopDecode(); * @endcode */ virtual int StopDecode() = 0; /** * @brief get video decode Image Data * @param[in] data:obtain Video Image info * @note * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * IHaasVideoCodec * mHaasVideoCodec = NULL; * mHaasVideoCodec = HaasVideoCodecInstance(); * ImageBuffer_t * image = NULL; * res_ res = 0; * res = mHaasVideoCodec->GetDecodeImageData(&image); * @endcode */ virtual int GetDecodeImageData(void *pkt, ImageBuffer_t** image) = 0; /** * @brief set Video encode config information * @param[in] config: obtain video encode information * @note * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * IHaasVideoCodec * mHaasVideoCodec = NULL; * mHaasVideoCodec = HaasVideoCodecInstance(); * EncodeConfig_t *config = xx; * res_ res = 0; * res = mHaasVideoCodec->EncodeConfig(config); * @endcode */ virtual int EncodeConfig(EncodeConfig_t* config) = 0; /** * @brief star video encode * @note * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * IHaasVideoCodec * mHaasVideoCodec = NULL; * mHaasVideoCodec = HaasVideoCodecInstance(); * res_ res = 0; * res = mHaasVideoCodec->StartEncode(); * @endcode */ virtual int StartEncode() = 0; /** * @brief stop video encode * @note * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * IHaasVideoCodec * mHaasVideoCodec = NULL; * mHaasVideoCodec = HaasVideoCodecInstance(); * res_ res = 0; * res = mHaasVideoCodec->StopEncode(); * @endcode */ virtual int StopEncode() = 0; /** * @brief get video encoder Data * @param[in] data:obtain Video Packet info * @note * @return * 0 successfully \n * -1 failed \n * @par Sample * @code * IHaasVideoCodec * mHaasVideoCodec = NULL; * mHaasVideoCodec = HaasVideoCodecInstance(); * VideoPacket_t data; * res_ res = 0; * res = mHaasVideoCodec->GetEncodePacketData(&data); * @endcode */ virtual int GetEncodePacketData(VideoPacket_t **data) = 0; }; extern "C" { /** * @brief Get HaasVideoCodec Instance * @param[in] type:VideoCodecType_t * @note NULL * @return * !0 successfully \n * NULL failed \n * @par Sample * @code * IHaasVideoCodec * mHaasVideoCodec = NULL; * mHaasVideoCodec = IHaasVideoCodecInstance(type); * @endcode */ IHaasVideoCodec* IHaasVideoCodecInstance(VideoCodecType_t type); } #endif
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/include/IHaasVideoCodec.h
C++
apache-2.0
4,688
/* * Copyright (C) 2020-2021 Alibaba Group Holding Limited */ #ifndef HAAS_COMMON_IMAGE_H #define HAAS_COMMON_IMAGE_H //#include <cstdint> #include <stdint.h> #include <stdlib.h> //#include <string> #include <string.h> /**@enum PixelFmt_t * @brief Pixel Format Value \n */ typedef enum { PIXEL_FMT_NONE = -1, PIXEL_FMT_YUV420P = 0, PIXEL_FMT_NV21 = 1, PIXEL_FMT_NV12 = 2, PIXEL_FMT_YUYV422 = 3, PIXEL_FMT_YUV422P = 4, PIXEL_FMT_RGB24 = 5, PIXEL_FMT_BGR24 = 6, PIXEL_FMT_ARGB = 7, PIXEL_FMT_RGBA = 8, PIXEL_FMT_ABGR = 9, PIXEL_FMT_BGRA = 10, PIXEL_FMT_RGB565 = 11, } PixelFmt_t; /**@struct ImagePos_t * @brief image position \n */ typedef struct { uint32_t x; uint32_t y; } ImagePos_t; /**@struct Point_t * @brief Point information \n */ typedef struct { uint32_t x; uint32_t y; } Point_t; /**@struct ImageSize_t * @brief Image size infomation \n */ typedef struct { uint32_t width; ///< image size width uint32_t height; ///< image size height } ImageSize_t; /**@struct ImageBuffer_t * @brief Image buffer information \n */ typedef struct { uint32_t stride; uint32_t width; uint32_t height; uint32_t size; PixelFmt_t format; uint32_t numPlane; uint8_t* address[3]; uint32_t linesize[3]; } ImageBuffer_t; #endif
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/include/base/HaasCommonImage.h
C
apache-2.0
1,369
/* * Copyright (C) 2020-2021 Alibaba Group Holding Limited */ #ifndef HAAS_COMMON_VIDEO_H #define HAAS_COMMON_VIDEO_H #include "base/include/base/HaasCommonImage.h" /**@enum VideoCodecID_t * @brief Video Codec ID Value \n */ typedef enum { VIDEO_CODEC_ID_NONE, VIDEO_CODEC_ID_H261, VIDEO_CODEC_ID_H263, VIDEO_CODEC_ID_MJPEG, VIDEO_CODEC_ID_LJPEG, VIDEO_CODEC_ID_H264, VIDEO_CODEC_ID_H265, } VideoCodecID_t; /**@struct VideoPacket_t * @brief Video Packet information \n */ typedef struct { int64_t pts; int64_t dts; uint8_t *data; int size; int64_t duration; int64_t pos; } VideoPacket_t; /**@struct DecodeConfig_t * @brief Decode Config information \n */ typedef struct { int type; int format; ImageSize_t *size; VideoPacket_t *data; } DecodeConfig_t; /**@struct ImageBuffer_t * @brief Encode Config information \n */ typedef struct { int type; int format; ImageSize_t *size; ImageBuffer_t *data; } EncodeConfig_t; #endif
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/include/base/HaasCommonVideo.h
C
apache-2.0
1,075
/* * Copyright (C) 2020-2021 Alibaba Group Holding Limited */ #ifndef HAAS_DATA_INPUT_DEF_H #define HAAS_DATA_INPUT_DEF_H #include "base/include/base/HaasCommonImage.h" /**@enum CameraNumber_t * @brief Camera Number \n */ typedef enum { DATA_INPUT_CAMERA_NUMBER_NONE = -1, DATA_INPUT_CAMERA_NUMBER_FRONT = 0, DATA_INPUT_CAMERA_NUMBER_BACK = 1, DATA_INPUT_CAMERA_NUMBER_MAX = 30, } CameraNumber_t; /**@enum DataInputType_t * @brief Input Data Source Type \n */ typedef enum { DATA_INPUT_SOURCE_NONE = -1, DATA_INPUT_SOURCE_IMAGE_BMP = 0, DATA_INPUT_SOURCE_IMAGE_GIF = 1, DATA_INPUT_SOURCE_IMAGE_PNG = 2, DATA_INPUT_SOURCE_IMAGE_JPG = 3, DATA_INPUT_SOURCE_VIDEO_FILE = 4, DATA_INPUT_SOURCE_VIDEO_RTMP = 5, DATA_INPUT_SOURCE_VIDEO_RTSP = 6, DATA_INPUT_SOURCE_CAMERA_USB = 7, DATA_INPUT_SOURCE_CAMERA_LOCAL = 8, DATA_INPUT_SOURCE_CAMERA_IP = 9, DATA_INPUT_SOURCE_MAX = 30, } DataInputType_t; #endif
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/include/base/HaasDataInputDef.h
C
apache-2.0
1,052
/* * Copyright (C) 2020-2021 Alibaba Group Holding Limited */ #ifndef HAAS_IMAGE_CODEC_DEF_H #define HAAS_IMAGE_CODEC_DEF_H #include "base/include/base/HaasCommonImage.h" /**@enum CodecImageType_t * @brief Codec Image Type \n */ typedef enum { CODEC_IMAGE_SOURCE_NONE = -1, CODEC_IMAG_SOURCE_IMAGE_PNG = 0, CODEC_IMAG_SOURCE_IMAGE_JPG = 1, CODEC_IMAG_SOURCE_IMAGE_BMP = 2, CODEC_IMAG_SOURCE_IMAGE_GIF = 3, CODEC_IMAG_SOURCE_MAX = 30, } CodecImageType_t; #endif
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/include/base/HaasImageCodecDef.h
C
apache-2.0
523
/* * Copyright (C) 2020-2021 Alibaba Group Holding Limited */ #ifndef HAAS_IMAGE_PROC_DEF_H #define HAAS_IMAGE_PROC_DEF_H #include "base/include/base/HaasCommonImage.h" /**@enum ImageProcType_t * @brief Image Proc Type \n */ typedef enum { IMAGE_PROC_NONE = -1, IMAGE_PROC_CPU = 0, IMAGE_PROC_OPENCV = 1, IMAGE_PROC_HAL = 2, IMAGE_PROC_MAX = 30, } ImageProcType_t; #endif
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/include/base/HaasImageProcDef.h
C
apache-2.0
437
/* * Copyright (C) 2020-2021 Alibaba Group Holding Limited */ #ifndef HAAS_ML_DEF_H #define HAAS_ML_DEF_H /**@enum MLEngineType_t * @brief ML Engine Type \n */ typedef enum { ML_ENGINE_NONE = -1, ML_ENGINE_MNN = 0, ML_ENGINE_CLOUD = 1, ML_ENGINE_ODLA = 2, ML_ENGINE_MAX = 30, } MLEngineType_t; #endif
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/include/base/HaasMLDef.h
C
apache-2.0
340
/* * Copyright (C) 2020-2021 Alibaba Group Holding Limited */ #ifndef HAAS_UI_DEF_H #define HAAS_UI_DEF_H /**@enum UIFrameworkType_t * @brief UI Framework Type \n */ typedef enum { UI_FRAMEWORK_NONE = -1, UI_FRAMEWORK_GREENUI = 0, UI_FRAMEWORK_FB = 1, UI_FRAMEWORK_LVGL = 2, UI_FRAMEWORK_SDL = 3, UI_FRAMEWORK_MAX = 30, } UIFrameworkType_t; #endif
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/include/base/HaasUIDef.h
C
apache-2.0
418
/* * Copyright (C) 2020-2021 Alibaba Group Holding Limited */ #ifndef HAAS_VIDEOCODEC_DEF_H #define HAAS_VIDEOCODEC_DEF_H /**@enum VideoCodecType_t * @brief Video Codec Type \n */ typedef enum { VIDEO_CODEC_NONE = -1, VIDEO_CODEC_FFMPEG = 0, VIDEO_CODEC_HAL = 1, VIDEO_CODEC_MAX = 30, } VideoCodecType_t; #endif
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/include/base/HaasVideoCodecDef.h
C
apache-2.0
359
#c interface #add include file include_directories(${CINTERFACEDIR}/include) #add src file list(APPEND SOURCEFILE "${CINTERFACEDIR}/src/WrapperIHaasDataInput.cpp") list(APPEND SOURCEFILE "${CINTERFACEDIR}/src/WrapperIHaasImageCodec.cpp") list(APPEND SOURCEFILE "${CINTERFACEDIR}/src/WrapperIHaasImageProc.cpp") list(APPEND SOURCEFILE "${CINTERFACEDIR}/src/WrapperIHaasML.cpp") list(APPEND SOURCEFILE "${CINTERFACEDIR}/src/WrapperIHaasUI.cpp") list(APPEND SOURCEFILE "${CINTERFACEDIR}/src/WrapperIHaasVideoCodec.cpp")
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/modules/c/cv.mk
Makefile
apache-2.0
519
/* * Copyright (C) 2020-2021 Alibaba Group Holding Limited */ #ifndef WRAPPER_IHAAS_DATA_INPUT_H #define WRAPPER_IHAAS_DATA_INPUT_H #include "base/include/base/HaasDataInputDef.h" #ifdef __cplusplus extern "C" { #endif void* DataInputCreateInstance(DataInputType_t type); void DataInputDestoryInstance(void* instance); int DataInputOpen(void* instance, char*filename); int DataInputOpen2(void* instance, int cameraNum); int DataInputClose(void* instance); bool DataInputCheckDataReady(void* instance); int DataInputRequestData(void* instance, ImageBuffer_t** image, int32_t timeout); int DataInputReleaseData(void* instance, ImageBuffer_t* image); #ifdef __cplusplus }; #endif #endif
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/modules/c/include/WrapperIHaasDataInput.h
C
apache-2.0
704
/* * Copyright (C) 2020-2021 Alibaba Group Holding Limited */ #ifndef WRAPPER_IHAAS_IMAGE_CODEC_H #define WRAPPER_IHAAS_IMAGE_CODEC_H #include "base/include/base/HaasCommonImage.h" #include "base/include/base/HaasImageCodecDef.h" #ifdef __cplusplus extern "C" { #endif void* ImageCodecCreateInstance(CodecImageType_t type); void ImageCodecDestoryInstance(void* instance); int ImageCodecImgRead(void* instance, ImageBuffer_t **image, char * filename); int ImageCodecImgReadMulti(void* instance, ImageBuffer_t **images, char * filename); int ImageCodecImgWrite(void* instance, ImageBuffer_t *image, char * filename); int ImageCodecImgWriteMulti(void* instance, ImageBuffer_t **images, char * filename); int ImageCodecImgDecode(void* instance, void *addr, ImageBuffer_t **image); ImageBuffer_t * ImageCodecImgDecode2(void* instance, const char * filename); int ImageCodecImgEncode(void* instance, void *addr, ImageBuffer_t ** image); int ImageCodechaveImageReader(void* instance, char * filename); int ImageCodechaveImageWriter(void* instance, char * filename); #ifdef __cplusplus }; #endif #endif
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/modules/c/include/WrapperIHaasImageCodec.h
C
apache-2.0
1,122
/* * Copyright (C) 2020-2021 Alibaba Group Holding Limited */ #ifndef WRAPPER_IHAAS_IMAGE_PROC_H #define WRAPPER_IHAAS_IMAGE_PROC_H #include "base/include/base/HaasCommonImage.h" #include "base/include/base/HaasImageProcDef.h" #ifdef __cplusplus extern "C" { #endif void* ImageProcCreateInstance(ImageProcType_t type); void ImageProcDestoryInstance(void* instance); int ImageProcOpen(void* instance); int ImageProcClose(void* instance); int ImageProcCvtColor(void* instance, const ImageBuffer_t* src, PixelFmt_t dst_format, ImageBuffer_t** dst); int ImageProcResize(void* instance, const ImageBuffer_t* src, const ImageSize_t dst_size, ImageBuffer_t** dst); int ImageProcImgCopy(void* instance, const ImageBuffer_t* src, ImageBuffer_t** dst); int ImageProcRectangle(void* instance, const ImageBuffer_t* src, int32_t left, int32_t top, int32_t right, int32_t bottom); int ImageProcCircle(void* instance, const ImageBuffer_t* src, int32_t center_x, int32_t center_y, int32_t radius); int ImageProcDrawMarker(void* instance, const ImageBuffer_t* src, Point_t *pt, int32_t type); int ImageProcFillPoly(void* instance, const ImageBuffer_t* src, Point_t** pts, int32_t color); int ImageProcPutText(void* instance, const ImageBuffer_t* src, char* text, int32_t left, int32_t top); int ImageProcDilateErode(void* instance, const ImageBuffer_t* src, ImageBuffer_t* dst, int32_t iMode, int32_t iThresh); void ImageProcImageAdd(void* instance, const ImageBuffer_t* src, ImageBuffer_t* added, ImageBuffer_t* dst); void ImageProcImageMinus(void* instance, const ImageBuffer_t* src, ImageBuffer_t* minused, ImageBuffer_t* dst); void ImageProcImageElementMultiply(void* instance, const ImageBuffer_t* src, ImageBuffer_t* multiplied, ImageBuffer_t* dst); void ImageProcImageElementDivide(void* instance, const ImageBuffer_t* src, ImageBuffer_t* divied, ImageBuffer_t* dst); int ImageProcWriteImageToFile(void* instance, const ImageBuffer_t* src, char* file_name); #ifdef __cplusplus }; #endif #endif
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/modules/c/include/WrapperIHaasImageProc.h
C
apache-2.0
2,183
/* * Copyright (C) 2020-2021 Alibaba Group Holding Limited */ #ifndef WRAPPER_IHAAS_ML_H #define WRAPPER_IHAAS_ML_H #include "base/include/base/HaasMLDef.h" #ifdef __cplusplus extern "C" { #endif void* MLCreateInstance(MLEngineType_t type); void MLDestoryInstance(void *instance); int MLConfig(void *instance, char *key, char *secret, char *endpoint, char *bucket); int MLSetInputData(void *instance, const char *dataPath, const char *compareDataPath); int MLLoadNet(void *instance, const char *modePath); int MLPredict(void *instance); int MLGetPredictResponses(void *instance, char *outResult, int len); int MLUnLoadNet(void *instance); #ifdef __cplusplus }; #endif #endif
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/modules/c/include/WrapperIHaasML.h
C
apache-2.0
728
/* * Copyright (C) 2020-2021 Alibaba Group Holding Limited */ #ifndef WRAPPER_IHAAS_UI_H #define WRAPPER_IHAAS_UI_H #include "base/include/base/HaasCommonImage.h" #include "base/include/base/HaasUIDef.h" #ifdef __cplusplus extern "C" { #endif void* UICreateInstance(UIFrameworkType_t type); void UIDestoryInstance(void* instance); int UIGetDisplayWidth(void* instance); int UIGetDisplayHeight(void* instance); int UIGetDisplayBacklight(void* instance); int UISetDisplayBacklight(void* instance, int32_t value); int UIGetDisplayType(void* instance); int UIGetDisplayFreq(void* instance); int UISetDisplayFreq(void* instance, int32_t freq); int UIDrawPoint(void* instance, Point_t *pt, int32_t color); int UIDrawLine(void* instance, Point_t *start, Point_t *end, int32_t color); int UIDrawRectangle(void* instance, int32_t left, int32_t top, int32_t right, int32_t bottom, int32_t color); int UIDrawCircle(void* instance, Point_t * center, int32_t radius, int32_t color); void UIDrawText(void* instance, char* text, int32_t size, int32_t color, int32_t left, int32_t top, int32_t right, int32_t bottom); bool UIDrawPixels(void* instance, int32_t* pixels, Point_t *pt, int32_t width, int32_t height); bool UIDrawImage(void* instance, char * path, Point_t *pt, int32_t width, int32_t height); void UIUpdateDisplay(void* instance); #ifdef __cplusplus }; #endif #endif
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/modules/c/include/WrapperIHaasUI.h
C
apache-2.0
1,438
/* * Copyright (C) 2020-2021 Alibaba Group Holding Limited */ #ifndef WRAPPER_IHAAS_VIDEO_CODEC_H #define WRAPPER_IHAAS_VIDEO_CODEC_H #include "base/include/base/HaasCommonVideo.h" #include "base/include/base/HaasCommonImage.h" #include "base/include/base/HaasVideoCodecDef.h" #ifdef __cplusplus extern "C" { #endif void* VideoCodecCreateInstance(VideoCodecType_t type); void VideoCodecDestoryInstance(void* instance); int VideoCodecOpen(void* instance); int VideoCodecClose(void* instance); int VideoCodecDecodeConfig(void* instance, DecodeConfig_t* config); int VideoCodecStartDecode(void* instance); int VideoCodecStopDecode(void* instance); int VideoCodecGetDecodeImageData(void* instance, void *pkt, ImageBuffer_t** image); int VideoCodecEncodeConfig(void* instance, EncodeConfig_t* config); int VideoCodecStartEncode(void* instance); int VideoCodecStopEncode(void* instance); int VideoCodecGetEncodePacketData(void* instance, VideoPacket_t **data); #ifdef __cplusplus }; #endif #endif
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/modules/c/include/WrapperIHaasVideoCodec.h
C
apache-2.0
1,016
#include "base/modules/c/include/WrapperIHaasDataInput.h" #include "base/include/IHaasDataInput.h" #include "ulog/ulog.h" #include "base/modules/core/include/HaasErrno.h" #define LOG_TAG "WRAPPER_DATAINPUT" void* DataInputCreateInstance(DataInputType_t type) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasDataInput* mIHaasDataInput = IHaasDataInputInstance(type); if (mIHaasDataInput == NULL) { LOGD(LOG_TAG, "IHaasDataInputInstance failed %s;\n", __func__); return NULL; } return (void*)mIHaasDataInput; #else return NULL; #endif } void DataInputDestoryInstance(void* instance) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasDataInput* mIHaasDataInput = (IHaasDataInput*)instance; if (mIHaasDataInput == NULL) { LOGD(LOG_TAG, "mIHaasDataInput is NULL %s;\n", __func__); return; } delete mIHaasDataInput; #endif } int DataInputOpen(void* instance, char* filename) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasDataInput* mIHaasDataInput = (IHaasDataInput*)instance; if (mIHaasDataInput == NULL) { LOGD(LOG_TAG, "mIHaasDataInput is NULL %s;\n", __func__); return -1; } int ret = mIHaasDataInput->Open(filename); return ret; #else return 0; #endif } int DataInputOpen2(void* instance, int cameraNum) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasDataInput* mIHaasDataInput = (IHaasDataInput*)instance; if (mIHaasDataInput == NULL) { LOGD(LOG_TAG, "mIHaasDataInput is NULL %s;\n", __func__); return -1; } int ret = mIHaasDataInput->Open(cameraNum); return ret; #else return 0; #endif } int DataInputClose(void* instance) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasDataInput* mIHaasDataInput = (IHaasDataInput*)instance; if (mIHaasDataInput == NULL) { LOGD(LOG_TAG, "mIHaasDataInput is NULL %s;\n", __func__); return -1; } int ret = mIHaasDataInput->Close(); return ret; #else return 0; #endif } bool DataInputCheckDataReady(void* instance) { LOGD(LOG_TAG, "entern %s; intance = %p;\n", __func__, instance); #if 0 IHaasDataInput* mIHaasDataInput = (IHaasDataInput*)instance; LOGD(LOG_TAG, "entern %s; mIHaasDataInput = %p;\n", __func__, mIHaasDataInput); if (mIHaasDataInput == NULL) { LOGD(LOG_TAG, "mIHaasDataInput is NULL %s;\n", __func__); return false; } bool ret = mIHaasDataInput->CheckDataReady(); return ret; #else return 0; #endif } int DataInputRequestData(void* instance, ImageBuffer_t** image, int32_t timeout) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasDataInput* mIHaasDataInput = (IHaasDataInput*)instance; if (mIHaasDataInput == NULL) { LOGD(LOG_TAG, "mIHaasDataInput is NULL %s;\n", __func__); return -1; } int ret = mIHaasDataInput->RequestData(image, timeout); return ret; #else return 0; #endif } int DataInputReleaseData(void* instance, ImageBuffer_t* image) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasDataInput* mIHaasDataInput = (IHaasDataInput*)instance; if (mIHaasDataInput == NULL) { LOGD(LOG_TAG, "mIHaasDataInput is NULL %s;\n", __func__); return -1; } int ret = mIHaasDataInput->ReleaseData(image); return ret; #else return 0; #endif }
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/modules/c/src/WrapperIHaasDataInput.cpp
C++
apache-2.0
3,414
#include "base/modules/c/include/WrapperIHaasImageCodec.h" #include "base/include/IHaasImageCodec.h" #include "ulog/ulog.h" #include "base/modules/core/include/HaasErrno.h" #define LOG_TAG "WRAPPER_IMAGECODEC" void* ImageCodecCreateInstance(CodecImageType_t type) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasImageCodec* mIHaasImageCodec = IHaasImageCodecInstance(type); if (mIHaasImageCodec == NULL) { LOGD(LOG_TAG, "IHaasInstance failed %s;\n", __func__); return NULL; } return (void*)mIHaasImageCodec; #else return NULL; #endif } void ImageCodecDestoryInstance(void* instance) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasImageCodec* mIHaasImageCodec = (IHaasImageCodec*)instance; if (mIHaasImageCodec == NULL) { LOGD(LOG_TAG, "mIHaasImageCodec is NULL %s;\n", __func__); return; } delete mIHaasImageCodec; #endif } int ImageCodecImgRead(void* instance, ImageBuffer_t **image, char * filename) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasImageCodec* mIHaasImageCodec = (IHaasImageCodec*)instance; if (mIHaasImageCodec == NULL) { LOGD(LOG_TAG, "mIHaasImageCodec is NULL %s;\n", __func__); return -1; } int ret = mIHaasImageCodec->ImgRead(image, filename); return ret; #else return 0; #endif } int ImageCodecImgReadMulti(void* instance, ImageBuffer_t **images, char * filename) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasImageCodec* mIHaasImageCodec = (IHaasImageCodec*)instance; if (mIHaasImageCodec == NULL) { LOGD(LOG_TAG, "mIHaasImageCodec is NULL %s;\n", __func__); return -1; } int ret = mIHaasImageCodec->ImgReadMulti(images, filename); return ret; #else return 0; #endif } int ImageCodecImgWrite(void* instance, ImageBuffer_t *image, char * filename) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasImageCodec* mIHaasImageCodec = (IHaasImageCodec*)instance; if (mIHaasImageCodec == NULL) { LOGD(LOG_TAG, "mIHaasImageCodec is NULL %s;\n", __func__); return -1; } int ret = mIHaasImageCodec->ImgWrite(image, filename); return ret; #else return 0; #endif } int ImageCodecImgWriteMulti(void* instance, ImageBuffer_t **images, char * filename) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasImageCodec* mIHaasImageCodec = (IHaasImageCodec*)instance; if (mIHaasImageCodec == NULL) { LOGD(LOG_TAG, "mIHaasImageCodec is NULL %s;\n", __func__); return -1; } int ret = mIHaasImageCodec->ImgWriteMulti(images, filename); return ret; #else return 0; #endif } int ImageCodecImgDecode(void* instance, void *addr, ImageBuffer_t **image) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasImageCodec* mIHaasImageCodec = (IHaasImageCodec*)instance; if (mIHaasImageCodec == NULL) { LOGD(LOG_TAG, "mIHaasImageCodec is NULL %s;\n", __func__); return -1; } int ret = mIHaasImageCodec->ImgDecode(addr, image); return ret; #else return 0; #endif } ImageBuffer_t * ImageCodecImgDecode2(void* instance, const char * filename) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasImageCodec* mIHaasImageCodec = (IHaasImageCodec*)instance; if (mIHaasImageCodec == NULL) { LOGD(LOG_TAG, "mIHaasImageCodec is NULL %s;\n", __func__); return NULL; } ImageBuffer_t * buffer = mIHaasImageCodec->ImgDecode(filename); return buffer; #else return NULL; #endif } int ImageCodecImgEncode(void* instance, void *addr, ImageBuffer_t ** image) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasImageCodec* mIHaasImageCodec = (IHaasImageCodec*)instance; if (mIHaasImageCodec == NULL) { LOGD(LOG_TAG, "mIHaasImageCodec is NULL %s;\n", __func__); return -1; } int ret = mIHaasImageCodec->ImgEncode(addr, image); return ret; #else return 0; #endif } int ImageCodechaveImageReader(void* instance, char * filename) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasImageCodec* mIHaasImageCodec = (IHaasImageCodec*)instance; if (mIHaasImageCodec == NULL) { LOGD(LOG_TAG, "mIHaasImageCodec is NULL %s;\n", __func__); return -1; } int ret = mIHaasImageCodec->haveImageReader(filename); return ret; #else return 0; #endif } int ImageCodechaveImageWriter(void* instance, char * filename) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasImageCodec* mIHaasImageCodec = (IHaasImageCodec*)instance; if (mIHaasImageCodec == NULL) { LOGD(LOG_TAG, "mIHaasImageCodec is NULL %s;\n", __func__); return -1; } int ret = mIHaasImageCodec->haveImageWriter(filename); return ret; #else return 0; #endif }
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/modules/c/src/WrapperIHaasImageCodec.cpp
C++
apache-2.0
4,847
#include "base/modules/c/include/WrapperIHaasImageProc.h" #include "base/include/IHaasImageProc.h" #include "ulog/ulog.h" #include "base/modules/core/include/HaasErrno.h" #define LOG_TAG "WRAPPER_PROC" void* ImageProcCreateInstance(ImageProcType_t type) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasImageProc* mIHaasImageProc = IHaasImageProcInstance(type); if (mIHaasImageProc == NULL) { LOGD(LOG_TAG, "IHaasInstance failed %s;\n", __func__); return NULL; } return (void*)mIHaasImageProc; #else return NULL; #endif } void ImageProcDestoryInstance(void* instance) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasImageProc* mIHaasImageProc = (IHaasImageProc*)instance; if (mIHaasImageProc == NULL) { LOGD(LOG_TAG, "mIHaasImageProc is NULL %s;\n", __func__); return; } delete mIHaasImageProc; #endif } int ImageProcOpen(void* instance) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasImageProc* mIHaasImageProc = (IHaasImageProc*)instance; if (mIHaasImageProc == NULL) { LOGD(LOG_TAG, "mIHaasImageProc is NULL %s;\n", __func__); return -1; } int ret = mIHaasImageProc->Open(); return ret; #else return 0; #endif } int ImageProcClose(void* instance) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasImageProc* mIHaasImageProc = (IHaasImageProc*)instance; if (mIHaasImageProc == NULL) { LOGD(LOG_TAG, "mIHaasImageProc is NULL %s;\n", __func__); return -1; } int ret = mIHaasImageProc->Close(); return ret; #else return 0; #endif } int ImageProcCvtColor(void* instance, const ImageBuffer_t* src, PixelFmt_t dst_format, ImageBuffer_t** dst) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasImageProc* mIHaasImageProc = (IHaasImageProc*)instance; if (mIHaasImageProc == NULL) { LOGD(LOG_TAG, "mIHaasImageProc is NULL %s;\n", __func__); return -1; } int ret = mIHaasImageProc->CvtColor(src, dst_format, dst); return ret; #else return 0; #endif } int ImageProcResize(void* instance, const ImageBuffer_t* src, const ImageSize_t dst_size, ImageBuffer_t** dst) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasImageProc* mIHaasImageProc = (IHaasImageProc*)instance; if (mIHaasImageProc == NULL) { LOGD(LOG_TAG, "mIHaasImageProc is NULL %s;\n", __func__); return -1; } int ret = mIHaasImageProc->Resize(src, dst_size, dst); return ret; #else return 0; #endif } int ImageProcImgCopy(void* instance, const ImageBuffer_t* src, ImageBuffer_t** dst) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasImageProc* mIHaasImageProc = (IHaasImageProc*)instance; if (mIHaasImageProc == NULL) { LOGD(LOG_TAG, "mIHaasImageProc is NULL %s;\n", __func__); return -1; } int ret = mIHaasImageProc->ImgCopy(src, dst); return ret; #else return 0; #endif } int ImageProcRectangle(void* instance, const ImageBuffer_t* src, int32_t left, int32_t top, int32_t right, int32_t bottom) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasImageProc* mIHaasImageProc = (IHaasImageProc*)instance; if (mIHaasImageProc == NULL) { LOGD(LOG_TAG, "mIHaasImageProc is NULL %s;\n", __func__); return -1; } int ret = mIHaasImageProc->Rectangle(src, left, top, right, bottom); return ret; #else return 0; #endif } int ImageProcCircle(void* instance, const ImageBuffer_t* src, int32_t center_x, int32_t center_y, int32_t radius) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasImageProc* mIHaasImageProc = (IHaasImageProc*)instance; if (mIHaasImageProc == NULL) { LOGD(LOG_TAG, "mIHaasImageProc is NULL %s;\n", __func__); return -1; } int ret = mIHaasImageProc->Circle(src, center_x, center_y, radius); return ret; #else return 0; #endif } int ImageProcDrawMarker(void* instance, const ImageBuffer_t* src, Point_t *pt, int32_t type) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasImageProc* mIHaasImageProc = (IHaasImageProc*)instance; if (mIHaasImageProc == NULL) { LOGD(LOG_TAG, "mIHaasImageProc is NULL %s;\n", __func__); return -1; } int ret = mIHaasImageProc->DrawMarker(src, pt, type); return ret; #else return 0; #endif } int ImageProcFillPoly(void* instance, const ImageBuffer_t* src, Point_t** pts, int32_t color) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasImageProc* mIHaasImageProc = (IHaasImageProc*)instance; if (mIHaasImageProc == NULL) { LOGD(LOG_TAG, "mIHaasImageProc is NULL %s;\n", __func__); return -1; } int ret = mIHaasImageProc->FillPoly(src, pts, color); return ret; #else return 0; #endif } int ImageProcPutText(void* instance, const ImageBuffer_t* src, char* text, int32_t left, int32_t top) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasImageProc* mIHaasImageProc = (IHaasImageProc*)instance; if (mIHaasImageProc == NULL) { LOGD(LOG_TAG, "mIHaasImageProc is NULL %s;\n", __func__); return -1; } int ret = mIHaasImageProc->PutText(src, text, left, top); return ret; #else return 0; #endif } int ImageProcDilateErode(void* instance, const ImageBuffer_t* src, ImageBuffer_t* dst, int32_t iMode, int32_t iThresh) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasImageProc* mIHaasImageProc = (IHaasImageProc*)instance; if (mIHaasImageProc == NULL) { LOGD(LOG_TAG, "mIHaasImageProc is NULL %s;\n", __func__); return -1; } int ret = mIHaasImageProc->DilateErode(src, dst, iMode, iThresh); return ret; #else return 0; #endif } void ImageProcImageAdd(void* instance, const ImageBuffer_t* src, ImageBuffer_t* added, ImageBuffer_t* dst) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasImageProc* mIHaasImageProc = (IHaasImageProc*)instance; if (mIHaasImageProc == NULL) { LOGD(LOG_TAG, "mIHaasImageProc is NULL %s;\n", __func__); return; } mIHaasImageProc->ImageAdd(src, added, dst); #endif } void ImageProcImageMinus(void* instance, const ImageBuffer_t* src, ImageBuffer_t* minused, ImageBuffer_t* dst) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasImageProc* mIHaasImageProc = (IHaasImageProc*)instance; if (mIHaasImageProc == NULL) { LOGD(LOG_TAG, "mIHaasImageProc is NULL %s;\n", __func__); return; } mIHaasImageProc->ImageMinus(src, minused, dst); #endif } void ImageProcImageElementMultiply(void* instance, const ImageBuffer_t* src, ImageBuffer_t* multiplied, ImageBuffer_t* dst) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasImageProc* mIHaasImageProc = (IHaasImageProc*)instance; if (mIHaasImageProc == NULL) { LOGD(LOG_TAG, "mIHaasImageProc is NULL %s;\n", __func__); return; } mIHaasImageProc->ImageElementMultiply(src, multiplied, dst); #endif } void ImageProcImageElementDivide(void* instance, const ImageBuffer_t* src, ImageBuffer_t* divied, ImageBuffer_t* dst) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasImageProc* mIHaasImageProc = (IHaasImageProc*)instance; if (mIHaasImageProc == NULL) { LOGD(LOG_TAG, "mIHaasImageProc is NULL %s;\n", __func__); return; } mIHaasImageProc->ImageElementDivide(src, divied, dst); #endif } int ImageProcWriteImageToFile(void* instance, const ImageBuffer_t* src, char* file_name) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasImageProc* mIHaasImageProc = (IHaasImageProc*)instance; if (mIHaasImageProc == NULL) { LOGD(LOG_TAG, "mIHaasImageProc is NULL %s;\n", __func__); return -1; } int ret = mIHaasImageProc->WriteImageToFile(src, file_name); return ret; #else return 0; #endif }
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/modules/c/src/WrapperIHaasImageProc.cpp
C++
apache-2.0
8,033
#include "base/modules/c/include/WrapperIHaasML.h" #include "base/include/IHaasML.h" #include "ulog/ulog.h" #include "base/modules/core/include/HaasErrno.h" #define LOG_TAG "WRAPPER_ML" void* MLCreateInstance(MLEngineType_t type) { LOGD(LOG_TAG, "entern %s;\n", __func__); IHaasML* mIHaasML = IHaasMLInstance(type); if (mIHaasML == NULL) { LOGD(LOG_TAG, "IHaasInstance failed %s;\n", __func__); return NULL; } return (void*)mIHaasML; } void MLDestoryInstance(void *instance) { LOGD(LOG_TAG, "entern %s;\n", __func__); IHaasML* mIHaasML = (IHaasML*)instance; if (mIHaasML == NULL) { LOGD(LOG_TAG, "mIHaasML is NULL %s;\n", __func__); return; } delete mIHaasML; } int MLConfig(void *instance, char *key, char *secret, char *endpoint, char *bucket) { LOGD(LOG_TAG, "key = %s;\n", key); LOGD(LOG_TAG, "secret = %s;\n", secret); LOGD(LOG_TAG, "endpoint = %s;\n", endpoint); LOGD(LOG_TAG, "bucket = %s;\n", bucket); IHaasML *mIHaasML = (IHaasML *)instance; if (mIHaasML == NULL) { LOGD(LOG_TAG, "mIHaasML is NULL %s;\n", __func__); return -1; } int ret = mIHaasML->Config(key, secret, endpoint, bucket); return ret; } int MLSetInputData(void *instance, const char *dataPath, const char *compareDataPath) { LOGD(LOG_TAG, "entern %s;\n", __func__); IHaasML* mIHaasML = (IHaasML*)instance; if (mIHaasML == NULL) { LOGD(LOG_TAG, "mIHaasML is NULL %s;\n", __func__); return -1; } int ret = mIHaasML->SetInputData(dataPath, compareDataPath); return ret; } int MLLoadNet(void *instance, const char *modePath) { LOGD(LOG_TAG, "entern %s;\n", __func__); IHaasML* mIHaasML = (IHaasML*)instance; if (mIHaasML == NULL) { LOGD(LOG_TAG, "mIHaasML is NULL %s;\n", __func__); return -1; } int ret = mIHaasML->LoadNet(modePath); return ret; } int MLPredict(void *instance) { LOGD(LOG_TAG, "entern %s;\n", __func__); IHaasML *mIHaasML = (IHaasML *)instance; if (mIHaasML == NULL) { LOGD(LOG_TAG, "mIHaasML is NULL %s;\n", __func__); return -1; } int ret = mIHaasML->Predict(); return ret; } int MLGetPredictResponses(void *instance, char *outResult, int len) { LOGD(LOG_TAG, "entern %s;\n", __func__); IHaasML *mIHaasML = (IHaasML *)instance; if (mIHaasML == NULL) { LOGD(LOG_TAG, "mIHaasML is NULL %s;\n", __func__); return -1; } int ret = mIHaasML->GetPredictResponses(outResult, len); LOGD(LOG_TAG, "out %s; ret = %d;\n", __func__, ret); return ret; } int MLUnLoadNet(void *instance) { LOGD(LOG_TAG, "entern %s;\n", __func__); IHaasML *mIHaasML = (IHaasML *)instance; if (mIHaasML == NULL) { LOGD(LOG_TAG, "mIHaasML is NULL %s;\n", __func__); return -1; } int ret = mIHaasML->UnLoadNet(); return ret; }
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/modules/c/src/WrapperIHaasML.cpp
C++
apache-2.0
2,963
#include "base/modules/c/include/WrapperIHaasUI.h" #include "base/include/IHaasUI.h" #include "ulog/ulog.h" #include "base/modules/core/include/HaasErrno.h" #define LOG_TAG "WRAPPER_UI" void* UICreateInstance(UIFrameworkType_t type) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasUI* mIHaasUI = IHaasUIInstance(type); if (mIHaasUI == NULL) { LOGD(LOG_TAG, "IHaasInstance failed %s;\n", __func__); return NULL; } return (void*)mIHaasUI; #else return NULL; #endif } void UIDestoryInstance(void* instance) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasUI* mIHaasUI = (IHaasUI*)instance; if (mIHaasUI == NULL) { LOGD(LOG_TAG, "mIHaasUI is NULL %s;\n", __func__); return; } delete mIHaasUI; #endif } int UIGetDisplayWidth(void* instance) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasUI* mIHaasUI = (IHaasUI*)instance; if (mIHaasUI == NULL) { LOGD(LOG_TAG, "mIHaasUI is NULL %s;\n", __func__); return -1; } int ret = mIHaasUI->GetDisplayWidth(); return ret; #else return 0; #endif } int UIGetDisplayHeight(void* instance) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasUI* mIHaasUI = (IHaasUI*)instance; if (mIHaasUI == NULL) { LOGD(LOG_TAG, "mIHaasUI is NULL %s;\n", __func__); return -1; } int ret = mIHaasUI->GetDisplayHeight(); return ret; #else return 0; #endif } int UIGetDisplayBacklight(void* instance) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasUI* mIHaasUI = (IHaasUI*)instance; if (mIHaasUI == NULL) { LOGD(LOG_TAG, "mIHaasUI is NULL %s;\n", __func__); return -1; } int ret = mIHaasUI->GetDisplayBacklight(); return ret; #else return 0; #endif } int UISetDisplayBacklight(void* instance, int32_t value) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasUI* mIHaasUI = (IHaasUI*)instance; if (mIHaasUI == NULL) { LOGD(LOG_TAG, "mIHaasUI is NULL %s;\n", __func__); return -1; } int ret = mIHaasUI->SetDisplayBacklight(value); return ret; #else return 0; #endif } int UIGetDisplayType(void* instance) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasUI* mIHaasUI = (IHaasUI*)instance; if (mIHaasUI == NULL) { LOGD(LOG_TAG, "mIHaasUI is NULL %s;\n", __func__); return -1; } int ret = mIHaasUI->GetDisplayType(); return ret; #else return 0; #endif } int UIGetDisplayFreq(void* instance) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasUI* mIHaasUI = (IHaasUI*)instance; if (mIHaasUI == NULL) { LOGD(LOG_TAG, "mIHaasUI is NULL %s;\n", __func__); return -1; } int ret = mIHaasUI->GetDisplayFreq(); return ret; #else return 0; #endif } int UISetDisplayFreq(void* instance, int32_t freq) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasUI* mIHaasUI = (IHaasUI*)instance; if (mIHaasUI == NULL) { LOGD(LOG_TAG, "mIHaasUI is NULL %s;\n", __func__); return -1; } int ret = mIHaasUI->SetDisplayFreq(freq); return ret; #else return 0; #endif } int UIDrawPoint(void* instance, Point_t *pt, int32_t color) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasUI* mIHaasUI = (IHaasUI*)instance; if (mIHaasUI == NULL) { LOGD(LOG_TAG, "mIHaasUI is NULL %s;\n", __func__); return -1; } int ret = mIHaasUI->DrawPoint(pt, color); return ret; #else return 0; #endif } int UIDrawLine(void* instance, Point_t *start, Point_t *end, int32_t color) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasUI* mIHaasUI = (IHaasUI*)instance; if (mIHaasUI == NULL) { LOGD(LOG_TAG, "mIHaasUI is NULL %s;\n", __func__); return -1; } int ret = mIHaasUI->DrawLine(start, end, color); return ret; #else return 0; #endif } int UIDrawRectangle(void* instance, int32_t left, int32_t top, int32_t right, int32_t bottom, int32_t color) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasUI* mIHaasUI = (IHaasUI*)instance; if (mIHaasUI == NULL) { LOGD(LOG_TAG, "mIHaasUI is NULL %s;\n", __func__); return -1; } int ret = mIHaasUI->DrawRectangle(left, top, right, bottom, color); return ret; #else return 0; #endif } int UIDrawCircle(void* instance, Point_t * center, int32_t radius, int32_t color) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasUI* mIHaasUI = (IHaasUI*)instance; if (mIHaasUI == NULL) { LOGD(LOG_TAG, "mIHaasUI is NULL %s;\n", __func__); return -1; } int ret = mIHaasUI->DrawCircle(center, radius, color); return ret; #else return 0; #endif } void UIDrawText(void* instance, char* text, int32_t size, int32_t color, int32_t left, int32_t top, int32_t right, int32_t bottom) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasUI* mIHaasUI = (IHaasUI*)instance; if (mIHaasUI == NULL) { LOGD(LOG_TAG, "mIHaasUI is NULL %s;\n", __func__); return; } mIHaasUI->DrawText(text, size, color, left, top, right, bottom); #endif } bool UIDrawPixels(void* instance, int32_t* pixels, Point_t *pt, int32_t width, int32_t height) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasUI* mIHaasUI = (IHaasUI*)instance; if (mIHaasUI == NULL) { LOGD(LOG_TAG, "mIHaasUI is NULL %s;\n", __func__); return false; } bool ret = mIHaasUI->DrawPixels(pixels, pt, width, height); return ret; #else return 0; #endif } bool UIDrawImage(void* instance, char * path, Point_t *pt, int32_t width, int32_t height) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasUI* mIHaasUI = (IHaasUI*)instance; if (mIHaasUI == NULL) { LOGD(LOG_TAG, "mIHaasUI is NULL %s;\n", __func__); return false; } bool ret = mIHaasUI->DrawImage(path, pt, width, height); return ret; #else return 0; #endif } void UIUpdateDisplay(void* instance) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasUI* mIHaasUI = (IHaasUI*)instance; if (mIHaasUI == NULL) { LOGD(LOG_TAG, "mIHaasUI is NULL %s;\n", __func__); return; } mIHaasUI->UpdateDisplay(); #endif }
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/modules/c/src/WrapperIHaasUI.cpp
C++
apache-2.0
6,381
#include "base/modules/c/include/WrapperIHaasVideoCodec.h" #include "base/include/IHaasVideoCodec.h" #include "ulog/ulog.h" #include "base/modules/core/include/HaasErrno.h" #define LOG_TAG "WRAPPER_VIDEOCODEC" void* VideoCodecCreateInstance(VideoCodecType_t type) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasVideoCodec* mIHaasVideoCodec = IHaasVideoCodecInstance(type); if (mIHaasVideoCodec == NULL) { LOGD(LOG_TAG, "IHaasInstance failed %s;\n", __func__); return NULL; } return (void*)mIHaasVideoCodec; #else return NULL; #endif } void VideoCodecDestoryInstance(void* instance) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasVideoCodec* mIHaasVideoCodec = (IHaasVideoCodec*)instance; if (mIHaasVideoCodec == NULL) { LOGD(LOG_TAG, "mIHaasVideoCodec is NULL %s;\n", __func__); return; } delete mIHaasVideoCodec; #endif } int VideoCodecOpen(void* instance) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasVideoCodec* mIHaasVideoCodec = (IHaasVideoCodec*)instance; if (mIHaasVideoCodec == NULL) { LOGD(LOG_TAG, "mIHaasVideoCodec is NULL %s;\n", __func__); return -1; } int ret = mIHaasVideoCodec->Open(); return ret; #else return 0; #endif } int VideoCodecClose(void* instance) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasVideoCodec* mIHaasVideoCodec = (IHaasVideoCodec*)instance; if (mIHaasVideoCodec == NULL) { LOGD(LOG_TAG, "mIHaasVideoCodec is NULL %s;\n", __func__); return -1; } int ret = mIHaasVideoCodec->Close(); return ret; #else return 0; #endif } int VideoCodecDecodeConfig(void* instance, DecodeConfig_t* config) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasVideoCodec* mIHaasVideoCodec = (IHaasVideoCodec*)instance; if (mIHaasVideoCodec == NULL) { LOGD(LOG_TAG, "mIHaasVideoCodec is NULL %s;\n", __func__); return -1; } int ret = mIHaasVideoCodec->DecodeConfig(config); return ret; #else return 0; #endif } int VideoCodecStartDecode(void* instance) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasVideoCodec* mIHaasVideoCodec = (IHaasVideoCodec*)instance; if (mIHaasVideoCodec == NULL) { LOGD(LOG_TAG, "mIHaasVideoCodec is NULL %s;\n", __func__); return -1; } int ret = mIHaasVideoCodec->StartDecode(); return ret; #else return 0; #endif } int VideoCodecStopDecode(void* instance) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasVideoCodec* mIHaasVideoCodec = (IHaasVideoCodec*)instance; if (mIHaasVideoCodec == NULL) { LOGD(LOG_TAG, "mIHaasVideoCodec is NULL %s;\n", __func__); return -1; } int ret = mIHaasVideoCodec->StopDecode(); return ret; #else return 0; #endif } int VideoCodecGetDecodeImageData(void* instance, void *pkt, ImageBuffer_t** image) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasVideoCodec* mIHaasVideoCodec = (IHaasVideoCodec*)instance; if (mIHaasVideoCodec == NULL) { LOGD(LOG_TAG, "mIHaasVideoCodec is NULL %s;\n", __func__); return -1; } int ret = mIHaasVideoCodec->GetDecodeImageData(pkt, image); return ret; #else return 0; #endif } int VideoCodecEncodeConfig(void* instance, EncodeConfig_t* config) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasVideoCodec* mIHaasVideoCodec = (IHaasVideoCodec*)instance; if (mIHaasVideoCodec == NULL) { LOGD(LOG_TAG, "mIHaasVideoCodec is NULL %s;\n", __func__); return -1; } int ret = mIHaasVideoCodec->EncodeConfig(config); return ret; #else return 0; #endif } int VideoCodecStartEncode(void* instance) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasVideoCodec* mIHaasVideoCodec = (IHaasVideoCodec*)instance; if (mIHaasVideoCodec == NULL) { LOGD(LOG_TAG, "mIHaasVideoCodec is NULL %s;\n", __func__); return -1; } int ret = mIHaasVideoCodec->StartEncode(); return ret; #else return 0; #endif } int VideoCodecStopEncode(void* instance) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasVideoCodec* mIHaasVideoCodec = (IHaasVideoCodec*)instance; if (mIHaasVideoCodec == NULL) { LOGD(LOG_TAG, "mIHaasVideoCodec is NULL %s;\n", __func__); return -1; } int ret = mIHaasVideoCodec->StopEncode(); return ret; #else return 0; #endif } int VideoCodecGetEncodePacketData(void* instance, VideoPacket_t **data) { LOGD(LOG_TAG, "entern %s;\n", __func__); #if 0 IHaasVideoCodec* mIHaasVideoCodec = (IHaasVideoCodec*)instance; if (mIHaasVideoCodec == NULL) { LOGD(LOG_TAG, "mIHaasVideoCodec is NULL %s;\n", __func__); return -1; } int ret = mIHaasVideoCodec->GetEncodePacketData(data); return ret; #else return 0; #endif }
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/modules/c/src/WrapperIHaasVideoCodec.cpp
C++
apache-2.0
4,941
#add include file include_directories(${CORE}/include) #add source file list(APPEND SOURCEFILE "${CORE}/src/HaasImageUtils.cpp")
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/modules/core/cv.mk
Makefile
apache-2.0
130
/* * Copyright (C) 2020-2021 Alibaba Group Holding Limited */ #ifndef HAL_ERRNO_H #define HAL_ERRNO_H #include <cerrno> enum { STATUS_OK = 0, STATUS_ERROR = -1, STATUS_BUSY = -2, STATUS_TIMEOUT = -3, STATUS_ENODEV = -4, STATUS_EPERM = -5, STATUS_EINVAL = -6, STATUS_EBADF = -7, STATUS_EBUSY = -8, STATUS_EAGAIN = -9, STATUS_ETIMEDOUT = -10, STATUS_ENOSPC = -11, STATUS_ENOMEM = -12, STATUS_ENOSUPPORT = -13, }; #endif
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/modules/core/include/HaasErrno.h
C
apache-2.0
553
/* * Copyright (C) 2020-2021 Alibaba Group Holding Limited */ #ifndef HAAS_IMAGE_UTILS_H #define HAAS_IMAGE_UTILS_H #include <stdint.h> #include "base/include/base/HaasCommonImage.h" class ImageUtils { public: static uint32_t GetSize(PixelFmt_t format, uint32_t width, uint32_t height); }; #endif
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/modules/core/include/HaasImageUtils.h
C++
apache-2.0
304
/* * Copyright (C) 2020-2021 Alibaba Group Holding Limited */ #ifndef HAAS_LOG_H #define HAAS_LOG_H #ifdef __cplusplus extern "C" { #endif #include <stdio.h> #include <string.h> //#define ENABLE_DEBUG #ifdef ENABLE_DEBUG #define LOG_ENABLE_D #endif #define LOG_ENABLE_I #define LOG_ENABLE_W #define LOG_ENABLE_E #ifdef LOG_ENABLE_D #define LOG_D(fmt, args...) \ do {printf("%s:%d", __FUNCTION__, __LINE__); printf("\n\r");printf(fmt,##args);printf("\n\r");} while(0) #else #define LOG_D(fmt, args...) #endif #ifdef LOG_ENABLE_I #define LOG_I(fmt, args...) \ do {printf("%s:%d", __FUNCTION__, __LINE__); printf("\n\r");printf(fmt,##args);printf("\n\r");} while(0) #else #define LOG_I(fmt, args...) #endif #ifdef LOG_ENABLE_W #define LOG_W(fmt, args...) \ do {printf("%s:%d", __FUNCTION__, __LINE__); printf("\n\r");printf(fmt,##args);printf("\n\r");} while(0) #else #define LOG_W(fmt, args...) #endif #ifdef LOG_ENABLE_E #define LOG_E(fmt, args...) \ do {printf("%s:%d", __FUNCTION__, __LINE__); printf("\n\r");printf(fmt,##args);printf("\n\r");} while(0) #else #define LOG_E(fmt, args...) #endif #ifdef __cplusplus } #endif #endif
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/modules/core/include/HaasLog.h
C
apache-2.0
1,161
#include "base/modules/core/include/HaasImageUtils.h" #include "ulog/ulog.h" #include "base/modules/core/include/HaasErrno.h" uint32_t ImageUtils::GetSize(PixelFmt_t format, uint32_t width, uint32_t height) { uint32_t baseSize = width * height; switch (format) { case PIXEL_FMT_YUV420P: case PIXEL_FMT_NV12: case PIXEL_FMT_NV21: return baseSize * 3 / 2; case PIXEL_FMT_YUYV422: return baseSize * 2; case PIXEL_FMT_RGB24: case PIXEL_FMT_BGR24: return baseSize * 3; case PIXEL_FMT_ARGB: case PIXEL_FMT_RGBA: case PIXEL_FMT_ABGR: case PIXEL_FMT_BGRA: return baseSize * 4; default: return STATUS_ERROR; } }
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/modules/core/src/HaasImageUtils.cpp
C++
apache-2.0
628
#add include file include_directories(${MLDIR}/include) #add source file list(APPEND SOURCEFILE "${MLDIR}/src/HaasML.cpp") list(APPEND SOURCEFILE "${MLDIR}/src/HaasMLCloud.cpp") list(APPEND SOURCEFILE "${MLDIR}/src/HaasMLMnn.cpp") #list(APPEND SOURCEFILE "${MLDIR}/src/HaasMLOlda.cpp")
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/modules/ml/cv.mk
Makefile
apache-2.0
288
#ifndef HAAS_ML_H #define HAAS_ML_H #include "base/include/IHaasML.h" #endif
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/modules/ml/include/HaasML.h
C
apache-2.0
78
#ifndef HAAS_ML_CLOUD_H #define HAAS_ML_CLOUD_H #include "base/include/IHaasML.h" #include <string> #include "ucloud_ai_common.h" #include "ucloud_ai_objectdet.h" #include "ucloud_ai_facebody.h" #include "ucloud_ai_imagerecog.h" #include "ucloud_ai_ocr.h" class HaasMLCloud : public IHaasML { public: HaasMLCloud(); virtual ~HaasMLCloud(); virtual int Config(char *key, char *secret, char *endpoint, char *bucket); virtual int SetInputData(const char *dataPath, const char *compareDataPath); virtual int LoadNet(const char *modePath); virtual int Predict(); virtual int GetPredictResponses(char *outResult, int len); virtual int UnLoadNet(); private: int PredictObjectDet(); int PredictFacebodyComparing(); int PredictAnimeStyle(); int PredictRecognizeExpression(); int PredictRecognizeCharacter(); int PredictDetectPedestrian(); int PredictDetectFruits(); int PredictRecognizeLicensePlate(); static int ObjectDetectCallback(void *result); static int AnimeStyleCallback(void *result); static int RecognizeExpressionCallback(void *result); static int FacebodyComparingCallback(void *result); static int RecognizeCharacterCallback(void *result); static int DetectPedestrianCallback(void *result); static int DetectFruitsCallback(void *result); static int RecognizeLicensePlateCallback(void *result); char * mDataPath; char * mAiMode; std::string mFacePath; }; #endif
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/modules/ml/include/HaasMLCloud.h
C++
apache-2.0
1,488
#ifndef HAAS_ML_MNN_H #define HAAS_ML_MNN_H #include "base/include/IHaasML.h" class HaasMLMnn : public IHaasML { public: HaasMLMnn(); virtual ~HaasMLMnn(); virtual int SetInputData(const char *dataPath, const char *compareDataPath); virtual int LoadNet(const char *modePath); virtual int Predict(); virtual int GetPredictResponses(char *outResult, int len); virtual int UnLoadNet(); }; #endif
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/modules/ml/include/HaasMLMnn.h
C++
apache-2.0
423
#ifndef HAAS_ML_OLDA_H #define HAAS_ML_OLDA_H #include "base/include/IHaasML.h" class HaasMLOlda : public IHaasML { public: HaasMLOlda(); virtual ~HaasMLOlda(); virtual int SetInputData(const char *dataPath, const char *compareDataPath); virtual int LoadNet(const char *modePath); virtual int Predict(); virtual int GetPredictResponses(char *outResult, int len); virtual int UnLoadNet(); private: int uai_get_img_dec_result(int8_t output_softmax[], int result_num, char *result); uint32_t input_scale; uint32_t input_shift; uint8_t *norm_img_data; int8_t out_output_Softmax[21]; }; #endif
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/modules/ml/include/HaasMLOlda.h
C++
apache-2.0
641
#ifndef HAAS_UAI_IMG_DATA_H #define HAAS_UAI_IMG_DATA_H #include "stdint.h" uint8_t uai_img_data[70*96*2] = { 138, 135, 122, 37, 105, 165, 97, 164, 81, 100, 73, 3, 56, 227, 48, 162, 48, 130, 48, 130, 48, 129, 48, 129, 48, 129, 56, 129, 56, 129, 56, 129, 56, 129, 56, 161, 64, 161, 64, 161, 64, 129, 72, 129, 72, 129, 80, 129, 80, 130, 80, 129, 88, 129, 88, 129, 88, 129, 96, 129, 96, 129, 96, 129, 96, 97, 96, 65, 96, 65, 96, 33, 96, 1, 96, 33, 104, 33, 104, 33, 112, 33, 120, 33, 120, 33, 128, 33, 128, 33, 128, 1, 128, 1, 128, 0, 128, 1, 128, 0, 120, 0, 120, 0, 112, 0, 104, 0, 96, 33, 80, 65, 64, 65, 56, 65, 56, 65, 56, 65, 48, 97, 48, 97, 40, 97, 40, 97, 40, 97, 40, 97, 40, 97, 40, 97, 40, 97, 40, 97, 138, 103, 122, 70, 105, 229, 89, 165, 81, 132, 73, 35, 56, 226, 56, 162, 48, 130, 48, 98, 48, 98, 48, 130, 56, 97, 56, 129, 56, 129, 56, 129, 64, 129, 64, 97, 64, 161, 72, 65, 72, 161, 80, 32, 80, 97, 88, 1, 96, 97, 96, 1, 96, 65, 88, 97, 96, 65, 96, 65, 104, 64, 104, 64, 104, 64, 104, 32, 112, 32, 112, 0, 104, 32, 104, 0, 112, 32, 120, 0, 120, 1, 128, 33, 128, 33, 136, 33, 136, 65, 144, 66, 144, 66, 144, 66, 152, 33, 152, 33, 152, 33, 152, 33, 152, 0, 168, 33, 176, 1, 120, 0, 80, 0, 64, 1, 56, 66, 56, 65, 48, 65, 48, 97, 48, 97, 48, 97, 48, 97, 48, 97, 40, 97, 40, 97, 40, 97, 40, 97, 138, 167, 122, 70, 105, 229, 89, 100, 81, 99, 73, 35, 64, 226, 56, 162, 56, 98, 48, 98, 56, 98, 56, 98, 56, 97, 56, 129, 64, 129, 64, 129, 64, 129, 72, 161, 80, 161, 80, 129, 88, 97, 112, 65, 144, 65, 160, 33, 168, 1, 176, 1, 192, 1, 200, 1, 208, 65, 208, 33, 224, 65, 232, 65, 232, 97, 232, 97, 232, 97, 224, 98, 224, 130, 216, 130, 216, 163, 216, 163, 208, 195, 200, 195, 200, 195, 208, 163, 208, 195, 208, 163, 208, 195, 208, 163, 216, 162, 216, 98, 224, 97, 232, 65, 240, 33, 248, 0, 248, 128, 240, 0, 176, 32, 104, 0, 80, 64, 64, 65, 56, 65, 56, 65, 48, 65, 48, 97, 48, 97, 48, 97, 48, 97, 48, 97, 48, 97, 48, 65, 138, 134, 130, 70, 113, 229, 97, 164, 81, 99, 73, 2, 64, 225, 56, 162, 56, 130, 56, 98, 56, 98, 56, 98, 56, 97, 64, 129, 64, 129, 64, 129, 72, 161, 72, 33, 88, 97, 96, 0, 128, 64, 168, 32, 200, 160, 224, 129, 224, 194, 224, 162, 225, 2, 241, 1, 241, 98, 241, 98, 241, 130, 233, 66, 233, 130, 224, 194, 225, 162, 234, 35, 234, 67, 226, 131, 226, 195, 235, 3, 235, 3, 234, 228, 227, 68, 236, 4, 243, 228, 244, 68, 244, 4, 244, 99, 252, 34, 253, 1, 251, 1, 252, 130, 250, 34, 252, 32, 249, 0, 248, 205, 248, 13, 176, 2, 96, 34, 80, 1, 56, 97, 56, 65, 48, 65, 48, 65, 48, 97, 48, 97, 48, 97, 48, 97, 48, 65, 48, 65, 138, 102, 122, 37, 114, 4, 97, 132, 81, 67, 73, 34, 64, 193, 56, 161, 56, 129, 56, 97, 56, 97, 56, 97, 64, 129, 64, 129, 72, 161, 72, 161, 80, 97, 96, 65, 120, 97, 176, 64, 232, 128, 248, 224, 249, 32, 249, 64, 249, 160, 249, 160, 249, 192, 250, 32, 250, 65, 250, 161, 250, 224, 251, 65, 251, 98, 251, 226, 252, 1, 252, 65, 252, 33, 252, 162, 253, 34, 253, 65, 253, 160, 254, 0, 254, 32, 254, 32, 254, 64, 254, 64, 254, 64, 254, 32, 254, 0, 253, 160, 253, 32, 252, 160, 252, 96, 250, 32, 250, 224, 249, 0, 248, 224, 232, 0, 168, 64, 96, 65, 72, 65, 56, 97, 56, 65, 56, 65, 48, 65, 48, 65, 48, 65, 48, 65, 48, 65, 48, 65, 146, 134, 130, 4, 113, 228, 97, 131, 81, 99, 73, 34, 64, 225, 64, 193, 56, 161, 56, 129, 56, 129, 64, 129, 64, 129, 64, 97, 72, 161, 80, 1, 88, 65, 120, 2, 184, 66, 240, 69, 249, 37, 249, 40, 250, 8, 252, 130, 251, 226, 253, 164, 253, 71, 253, 101, 253, 164, 254, 4, 253, 227, 254, 131, 254, 35, 254, 67, 254, 164, 255, 4, 255, 36, 255, 99, 255, 100, 247, 133, 247, 196, 247, 226, 247, 226, 247, 227, 247, 228, 247, 229, 247, 230, 247, 229, 247, 196, 247, 141, 255, 80, 255, 81, 252, 174, 254, 76, 251, 12, 251, 64, 249, 224, 248, 1, 216, 33, 136, 0, 72, 96, 64, 97, 56, 97, 56, 65, 48, 65, 48, 65, 48, 65, 56, 65, 56, 65, 56, 65, 138, 166, 122, 5, 105, 196, 97, 131, 89, 99, 73, 34, 65, 1, 64, 193, 64, 161, 64, 129, 64, 161, 64, 129, 64, 129, 72, 161, 72, 129, 88, 97, 120, 65, 192, 96, 249, 0, 249, 64, 250, 0, 250, 160, 252, 0, 252, 0, 253, 32, 252, 160, 253, 0, 253, 64, 254, 96, 254, 32, 255, 0, 254, 192, 254, 224, 247, 0, 246, 224, 247, 96, 239, 192, 239, 224, 239, 224, 239, 224, 239, 224, 239, 224, 239, 224, 239, 224, 239, 224, 239, 224, 239, 224, 239, 224, 239, 224, 239, 224, 247, 192, 245, 224, 253, 224, 252, 32, 252, 224, 250, 32, 250, 96, 248, 64, 224, 64, 144, 97, 80, 65, 72, 97, 64, 97, 56, 65, 56, 65, 56, 65, 56, 65, 56, 65, 56, 65, 56, 65, 138, 166, 130, 69, 113, 228, 97, 131, 89, 67, 81, 34, 72, 226, 64, 193, 64, 193, 64, 129, 64, 129, 64, 97, 64, 161, 72, 1, 88, 96, 120, 0, 176, 32, 240, 33, 249, 161, 249, 162, 251, 98, 251, 97, 252, 225, 255, 9, 253, 169, 255, 40, 255, 76, 255, 137, 247, 201, 247, 228, 247, 229, 247, 229, 247, 231, 247, 237, 247, 237, 247, 238, 247, 237, 247, 237, 247, 239, 247, 241, 247, 243, 247, 243, 247, 243, 247, 244, 247, 244, 247, 244, 247, 244, 247, 237, 247, 234, 247, 233, 247, 228, 246, 66, 254, 225, 253, 162, 252, 193, 250, 192, 250, 96, 249, 128, 232, 160, 153, 1, 88, 97, 72, 65, 64, 97, 56, 65, 56, 65, 56, 65, 56, 65, 56, 65, 56, 65, 56, 65, 146, 166, 130, 69, 113, 228, 97, 132, 89, 99, 81, 34, 72, 225, 64, 193, 64, 161, 64, 129, 64, 129, 72, 129, 72, 97, 96, 96, 136, 64, 192, 96, 240, 192, 249, 160, 250, 192, 251, 96, 252, 64, 252, 192, 253, 128, 253, 192, 254, 193, 254, 161, 247, 225, 247, 227, 247, 228, 247, 228, 247, 230, 247, 231, 247, 232, 247, 234, 247, 235, 247, 236, 247, 238, 247, 239, 247, 239, 247, 239, 247, 239, 247, 240, 247, 239, 247, 239, 247, 239, 247, 239, 247, 240, 247, 238, 247, 234, 239, 229, 247, 228, 246, 36, 255, 66, 251, 194, 253, 32, 250, 224, 250, 160, 248, 97, 225, 32, 152, 225, 88, 97, 72, 97, 64, 65, 56, 65, 56, 65, 56, 65, 56, 65, 56, 65, 56, 65, 56, 65, 146, 166, 130, 69, 113, 197, 97, 132, 89, 35, 73, 34, 72, 194, 72, 161, 64, 161, 64, 97, 64, 129, 72, 1, 96, 64, 128, 2, 192, 2, 240, 65, 249, 225, 250, 33, 251, 160, 253, 6, 253, 71, 255, 33, 254, 100, 254, 228, 255, 34, 255, 195, 247, 227, 247, 228, 247, 229, 247, 229, 247, 237, 247, 243, 247, 243, 247, 244, 247, 244, 247, 244, 247, 244, 247, 244, 247, 245, 247, 246, 247, 247, 247, 247, 247, 247, 247, 246, 247, 245, 247, 245, 247, 240, 247, 235, 239, 231, 239, 228, 247, 162, 247, 101, 254, 5, 254, 137, 252, 170, 250, 165, 250, 69, 240, 2, 209, 97, 144, 65, 96, 161, 72, 129, 64, 97, 56, 97, 56, 97, 56, 97, 56, 65, 56, 65, 48, 65, 56, 65, 138, 198, 130, 69, 113, 229, 97, 132, 89, 67, 81, 34, 72, 193, 72, 161, 72, 129, 72, 129, 80, 97, 88, 97, 120, 32, 200, 0, 249, 32, 249, 224, 250, 128, 251, 128, 252, 160, 253, 0, 253, 225, 254, 1, 254, 130, 255, 4, 255, 134, 247, 198, 247, 228, 247, 229, 247, 233, 247, 234, 247, 235, 247, 235, 247, 234, 247, 234, 247, 235, 247, 236, 247, 237, 247, 238, 247, 238, 247, 238, 247, 238, 247, 239, 247, 239, 247, 239, 247, 238, 247, 237, 247, 234, 239, 228, 239, 224, 239, 96, 239, 64, 253, 128, 253, 192, 251, 192, 251, 224, 249, 224, 249, 192, 225, 0, 185, 129, 137, 65, 96, 225, 80, 161, 64, 97, 64, 97, 56, 97, 56, 97, 56, 97, 56, 65, 48, 65, 48, 65, 138, 166, 122, 37, 113, 197, 97, 100, 89, 35, 81, 3, 72, 194, 72, 162, 72, 161, 72, 65, 80, 97, 88, 1, 160, 0, 240, 106, 249, 234, 249, 192, 251, 160, 251, 192, 253, 97, 255, 104, 254, 105, 254, 229, 255, 41, 255, 41, 255, 169, 247, 71, 247, 230, 247, 230, 247, 230, 247, 234, 247, 235, 247, 237, 247, 238, 247, 239, 247, 239, 247, 238, 247, 238, 247, 238, 247, 237, 247, 237, 247, 237, 247, 235, 247, 234, 247, 234, 247, 234, 247, 235, 247, 234, 239, 228, 239, 65, 239, 193, 246, 1, 255, 108, 252, 140, 252, 98, 250, 161, 248, 70, 241, 134, 192, 34, 145, 131, 121, 66, 97, 2, 80, 161, 64, 97, 56, 97, 56, 97, 56, 97, 48, 97, 48, 65, 48, 65, 48, 65, 138, 134, 130, 69, 105, 164, 97, 131, 89, 35, 81, 2, 72, 194, 72, 162, 72, 129, 80, 129, 88, 65, 128, 0, 208, 192, 249, 96, 250, 192, 251, 32, 252, 64, 253, 32, 253, 225, 254, 65, 254, 196, 255, 8, 255, 41, 255, 74, 254, 69, 254, 160, 254, 192, 255, 32, 247, 64, 247, 97, 247, 96, 247, 128, 247, 160, 247, 192, 247, 224, 247, 224, 239, 224, 239, 224, 239, 224, 239, 224, 239, 224, 239, 224, 239, 224, 239, 224, 239, 224, 247, 128, 247, 96, 246, 129, 246, 34, 252, 227, 253, 65, 251, 192, 251, 224, 250, 64, 250, 64, 241, 64, 209, 193, 161, 225, 137, 194, 113, 98, 97, 65, 88, 161, 72, 97, 64, 97, 56, 97, 56, 65, 56, 65, 48, 65, 48, 65, 48, 65, 146, 102, 130, 69, 113, 196, 97, 131, 89, 66, 81, 2, 72, 225, 72, 161, 72, 161, 80, 0, 112, 64, 168, 33, 225, 97, 252, 32, 251, 0, 252, 167, 253, 71, 255, 99, 254, 166, 254, 196, 255, 70, 254, 231, 255, 71, 254, 167, 255, 39, 255, 40, 254, 100, 254, 98, 254, 129, 254, 161, 254, 162, 254, 163, 254, 162, 246, 194, 246, 194, 247, 2, 247, 2, 247, 3, 246, 227, 246, 195, 246, 195, 246, 195, 246, 131, 246, 99, 246, 4, 246, 37, 245, 196, 255, 79, 252, 206, 253, 103, 252, 6, 249, 101, 250, 101, 240, 102, 233, 165, 200, 35, 162, 5, 145, 132, 129, 196, 113, 130, 97, 33, 80, 193, 72, 129, 64, 97, 56, 97, 56, 97, 48, 97, 48, 65, 48, 65, 48, 65, 146, 70, 130, 69, 113, 196, 97, 131, 89, 66, 81, 1, 80, 193, 80, 161, 80, 161, 80, 97, 112, 33, 184, 1, 233, 224, 250, 64, 252, 32, 252, 128, 254, 32, 254, 96, 254, 192, 255, 68, 255, 35, 255, 68, 255, 72, 254, 232, 254, 6, 253, 2, 252, 97, 252, 129, 252, 32, 252, 96, 252, 129, 252, 129, 252, 129, 252, 161, 252, 162, 252, 130, 252, 98, 252, 98, 244, 67, 244, 68, 244, 35, 244, 35, 244, 35, 244, 3, 243, 227, 243, 99, 243, 2, 250, 226, 250, 193, 250, 97, 250, 160, 249, 160, 249, 224, 241, 128, 210, 33, 178, 35, 154, 67, 146, 4, 130, 4, 113, 131, 89, 33, 80, 193, 72, 129, 64, 97, 56, 97, 56, 65, 56, 65, 56, 65, 56, 65, 56, 65, 146, 134, 130, 36, 113, 163, 97, 130, 89, 97, 81, 1, 80, 225, 80, 161, 80, 161, 96, 1, 136, 0, 192, 130, 242, 1, 252, 167, 252, 71, 255, 74, 254, 74, 255, 64, 247, 130, 247, 131, 247, 129, 254, 224, 255, 70, 255, 72, 254, 38, 251, 14, 253, 45, 250, 35, 252, 33, 251, 193, 251, 225, 251, 225, 251, 193, 251, 193, 251, 129, 251, 98, 243, 66, 243, 2, 243, 34, 251, 194, 251, 98, 251, 98, 251, 66, 251, 33, 251, 1, 251, 130, 250, 193, 240, 97, 242, 33, 240, 129, 233, 98, 232, 131, 217, 162, 192, 99, 170, 36, 154, 36, 154, 69, 138, 4, 121, 228, 113, 131, 89, 33, 80, 193, 72, 129, 64, 97, 56, 97, 56, 97, 56, 97, 56, 65, 56, 65, 56, 65, 146, 134, 130, 69, 113, 131, 97, 130, 89, 98, 89, 1, 80, 225, 80, 161, 88, 129, 88, 97, 128, 1, 208, 65, 250, 32, 251, 96, 253, 128, 254, 0, 255, 65, 247, 97, 247, 224, 247, 227, 247, 163, 247, 32, 247, 99, 253, 3, 252, 193, 252, 98, 250, 195, 249, 162, 248, 225, 249, 33, 248, 225, 240, 225, 240, 193, 240, 193, 240, 193, 240, 225, 249, 1, 249, 33, 241, 33, 240, 225, 240, 97, 240, 65, 232, 97, 232, 65, 232, 65, 240, 65, 240, 65, 240, 33, 248, 65, 248, 192, 241, 33, 217, 129, 178, 2, 162, 68, 162, 100, 154, 68, 146, 133, 138, 5, 122, 4, 105, 131, 89, 34, 80, 193, 72, 129, 64, 97, 56, 97, 56, 97, 56, 97, 56, 65, 56, 65, 56, 65, 146, 134, 130, 101, 113, 132, 97, 99, 97, 66, 89, 34, 80, 225, 80, 161, 88, 129, 96, 65, 136, 1, 208, 65, 242, 65, 252, 128, 253, 160, 255, 6, 255, 232, 247, 226, 247, 227, 247, 227, 247, 228, 247, 132, 247, 99, 254, 137, 253, 39, 232, 162, 235, 131, 232, 196, 225, 34, 240, 97, 232, 129, 224, 65, 216, 65, 216, 97, 216, 97, 216, 161, 216, 64, 208, 64, 200, 32, 192, 33, 184, 33, 176, 64, 168, 32, 168, 0, 160, 33, 152, 64, 152, 32, 160, 65, 160, 129, 152, 1, 161, 97, 153, 66, 154, 4, 154, 101, 154, 102, 154, 100, 146, 165, 138, 37, 121, 227, 105, 130, 89, 1, 80, 193, 72, 129, 64, 97, 56, 97, 56, 97, 56, 97, 56, 97, 56, 97, 56, 65, 146, 102, 130, 37, 105, 131, 97, 99, 97, 35, 89, 2, 88, 193, 88, 161, 96, 129, 96, 97, 144, 33, 216, 65, 250, 97, 252, 96, 253, 224, 254, 160, 247, 224, 247, 229, 247, 232, 239, 227, 239, 224, 247, 160, 254, 160, 252, 96, 252, 225, 250, 1, 249, 65, 249, 97, 240, 97, 208, 1, 184, 1, 176, 1, 176, 1, 176, 1, 176, 1, 168, 0, 160, 0, 160, 0, 152, 0, 144, 1, 144, 1, 144, 1, 144, 33, 136, 33, 128, 33, 128, 65, 128, 66, 120, 130, 120, 162, 129, 66, 137, 131, 146, 4, 146, 68, 154, 100, 154, 100, 146, 68, 146, 197, 130, 37, 113, 195, 97, 98, 88, 226, 72, 162, 64, 97, 64, 97, 56, 65, 56, 97, 56, 97, 56, 97, 56, 65, 64, 65, 138, 133, 122, 37, 105, 100, 97, 99, 97, 35, 88, 226, 88, 193, 88, 161, 96, 129, 96, 65, 152, 33, 216, 97, 242, 129, 252, 64, 254, 32, 255, 100, 247, 229, 247, 233, 247, 232, 239, 229, 247, 232, 247, 229, 247, 129, 252, 98, 253, 1, 249, 1, 249, 97, 216, 66, 192, 225, 160, 1, 112, 97, 96, 33, 96, 65, 96, 65, 96, 65, 96, 65, 96, 65, 96, 97, 88, 97, 88, 65, 88, 97, 80, 65, 80, 65, 80, 65, 72, 65, 72, 33, 80, 129, 88, 65, 112, 225, 121, 2, 129, 131, 129, 227, 130, 36, 138, 68, 146, 132, 146, 100, 138, 164, 130, 36, 113, 195, 97, 67, 80, 162, 72, 129, 64, 98, 64, 66, 64, 65, 56, 65, 56, 97, 56, 97, 56, 65, 56, 65, 130, 69, 122, 36, 105, 68, 97, 99, 97, 35, 89, 2, 88, 193, 88, 161, 96, 129, 104, 65, 160, 33, 224, 97, 242, 161, 252, 192, 254, 96, 247, 1, 239, 227, 247, 235, 247, 238, 247, 233, 239, 229, 247, 226, 247, 162, 252, 67, 253, 0, 249, 128, 249, 1, 216, 0, 176, 64, 136, 97, 104, 65, 96, 65, 96, 65, 96, 65, 88, 65, 88, 65, 88, 65, 88, 65, 88, 65, 80, 65, 80, 65, 80, 65, 80, 65, 80, 65, 80, 65, 80, 65, 80, 97, 80, 162, 96, 194, 105, 35, 113, 131, 121, 228, 130, 36, 138, 68, 138, 100, 138, 100, 138, 68, 122, 3, 105, 194, 89, 67, 72, 162, 64, 161, 64, 97, 64, 65, 64, 65, 56, 65, 56, 65, 56, 65, 56, 65, 64, 65, 138, 101, 122, 5, 113, 100, 97, 99, 97, 35, 89, 2, 88, 193, 88, 161, 96, 161, 104, 65, 168, 33, 224, 97, 242, 225, 252, 225, 254, 129, 247, 192, 247, 226, 247, 235, 247, 239, 247, 234, 247, 233, 239, 229, 247, 193, 244, 99, 253, 2, 249, 65, 241, 33, 208, 1, 168, 96, 128, 32, 96, 65, 96, 65, 88, 65, 80, 65, 80, 65, 80, 65, 80, 65, 80, 65, 80, 65, 80, 65, 72, 65, 72, 65, 72, 65, 72, 65, 72, 65, 72, 65, 72, 97, 80, 130, 88, 226, 97, 66, 113, 163, 122, 4, 130, 68, 138, 101, 138, 100, 138, 100, 130, 100, 121, 228, 105, 163, 88, 226, 80, 194, 72, 130, 64, 97, 56, 65, 56, 65, 56, 65, 56, 65, 56, 65, 56, 65, 64, 65, 138, 134, 129, 229, 113, 132, 105, 99, 97, 3, 88, 226, 88, 193, 88, 161, 96, 161, 104, 65, 168, 65, 232, 65, 243, 65, 252, 161, 254, 160, 247, 192, 239, 227, 247, 235, 247, 239, 247, 233, 247, 233, 239, 230, 247, 226, 252, 67, 253, 33, 249, 33, 249, 1, 208, 1, 160, 64, 120, 33, 88, 65, 88, 33, 80, 65, 80, 65, 72, 65, 72, 65, 72, 65, 72, 65, 72, 65, 72, 65, 72, 65, 72, 65, 72, 65, 72, 65, 72, 65, 72, 65, 72, 97, 80, 161, 89, 1, 97, 98, 105, 195, 122, 4, 130, 69, 138, 101, 138, 101, 138, 69, 130, 36, 121, 196, 105, 99, 89, 35, 72, 130, 64, 130, 64, 66, 64, 65, 56, 65, 56, 65, 56, 65, 64, 65, 64, 65, 64, 65, 138, 70, 129, 229, 113, 164, 105, 100, 97, 3, 88, 226, 88, 194, 88, 161, 104, 161, 104, 33, 168, 65, 232, 97, 243, 130, 253, 34, 255, 33, 247, 224, 239, 227, 247, 235, 247, 240, 247, 236, 247, 234, 239, 230, 239, 226, 252, 35, 253, 34, 248, 225, 240, 193, 200, 1, 152, 65, 120, 33, 88, 65, 88, 65, 80, 65, 80, 65, 72, 65, 72, 65, 72, 65, 72, 65, 72, 65, 72, 65, 72, 65, 64, 65, 64, 65, 64, 65, 64, 65, 72, 65, 72, 97, 72, 161, 81, 1, 89, 98, 105, 162, 114, 3, 130, 36, 138, 69, 138, 101, 138, 100, 130, 68, 121, 196, 105, 131, 89, 2, 80, 162, 72, 130, 64, 66, 64, 65, 56, 65, 56, 65, 64, 65, 64, 65, 64, 65, 64, 65, 130, 70, 121, 164, 113, 163, 105, 99, 97, 35, 96, 226, 88, 194, 96, 161, 104, 129, 112, 33, 168, 97, 232, 129, 243, 226, 252, 162, 255, 97, 247, 224, 239, 227, 247, 236, 247, 241, 247, 236, 247, 234, 239, 230, 239, 227, 252, 68, 253, 1, 249, 65, 240, 129, 200, 0, 152, 32, 128, 33, 104, 65, 80, 65, 80, 65, 72, 65, 72, 65, 72, 65, 72, 65, 72, 65, 72, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 72, 97, 72, 161, 81, 1, 89, 97, 105, 194, 114, 3, 122, 36, 130, 69, 138, 101, 138, 69, 130, 101, 121, 228, 105, 132, 89, 3, 80, 194, 72, 130, 64, 97, 56, 65, 56, 65, 56, 65, 64, 65, 64, 65, 64, 65, 64, 65, 138, 70, 121, 197, 113, 164, 97, 99, 89, 34, 88, 226, 88, 194, 88, 161, 104, 129, 112, 33, 176, 96, 232, 129, 244, 34, 252, 226, 247, 129, 247, 224, 239, 228, 247, 238, 247, 242, 247, 237, 247, 235, 239, 230, 239, 226, 244, 36, 245, 35, 249, 66, 240, 129, 192, 1, 144, 65, 120, 65, 96, 65, 80, 65, 72, 65, 72, 65, 72, 65, 72, 65, 72, 65, 72, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 72, 97, 72, 193, 81, 1, 89, 130, 105, 194, 114, 3, 122, 68, 130, 100, 138, 101, 138, 100, 130, 68, 121, 196, 105, 163, 97, 35, 80, 194, 72, 130, 64, 97, 64, 65, 56, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 130, 37, 121, 197, 105, 132, 97, 68, 89, 35, 88, 226, 88, 194, 96, 161, 112, 97, 120, 33, 176, 97, 232, 225, 244, 130, 253, 3, 247, 161, 247, 226, 247, 231, 247, 239, 247, 242, 247, 238, 247, 236, 239, 231, 239, 226, 244, 35, 253, 33, 249, 33, 248, 129, 192, 0, 144, 64, 120, 33, 104, 65, 80, 65, 80, 65, 72, 65, 72, 65, 72, 65, 72, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 97, 72, 129, 80, 193, 89, 1, 97, 98, 105, 195, 114, 3, 122, 68, 130, 100, 138, 133, 138, 101, 130, 36, 121, 195, 113, 195, 96, 227, 88, 162, 72, 98, 72, 66, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 97, 130, 37, 113, 132, 97, 163, 89, 67, 89, 34, 89, 2, 88, 193, 96, 161, 112, 129, 120, 33, 176, 97, 224, 130, 236, 162, 245, 36, 247, 195, 247, 228, 247, 234, 247, 240, 247, 242, 247, 238, 247, 237, 239, 230, 239, 224, 236, 3, 245, 4, 249, 34, 240, 193, 200, 1, 144, 32, 120, 65, 96, 65, 80, 65, 80, 65, 72, 65, 72, 65, 72, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 72, 97, 80, 162, 89, 2, 97, 98, 105, 195, 122, 4, 130, 68, 138, 100, 138, 100, 138, 68, 130, 4, 121, 196, 105, 163, 88, 98, 80, 225, 72, 130, 72, 98, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 97, 138, 5, 113, 196, 97, 163, 97, 67, 89, 2, 88, 226, 88, 161, 104, 129, 112, 97, 128, 33, 176, 161, 225, 66, 244, 226, 253, 131, 247, 225, 247, 228, 247, 235, 247, 241, 247, 242, 247, 239, 247, 238, 239, 231, 239, 225, 244, 3, 245, 35, 248, 161, 248, 225, 192, 1, 136, 32, 120, 33, 104, 65, 88, 65, 80, 65, 72, 65, 72, 65, 72, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 72, 129, 80, 193, 89, 33, 97, 98, 105, 195, 122, 36, 130, 100, 138, 101, 138, 133, 138, 133, 129, 229, 113, 164, 105, 99, 89, 3, 80, 162, 72, 98, 72, 66, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 130, 5, 113, 196, 105, 163, 89, 34, 81, 2, 88, 194, 88, 162, 96, 161, 112, 129, 128, 33, 176, 129, 225, 162, 245, 34, 245, 163, 239, 226, 247, 229, 247, 237, 247, 242, 247, 242, 247, 240, 247, 238, 239, 231, 247, 225, 235, 195, 237, 4, 240, 162, 240, 225, 200, 1, 144, 32, 120, 65, 96, 65, 88, 65, 80, 65, 72, 65, 72, 65, 72, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 97, 64, 65, 64, 65, 64, 65, 72, 130, 80, 194, 89, 34, 97, 98, 105, 195, 122, 36, 138, 100, 138, 132, 138, 100, 138, 68, 122, 4, 113, 164, 97, 99, 89, 3, 80, 162, 72, 98, 72, 66, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 129, 229, 113, 196, 105, 163, 89, 67, 89, 2, 88, 226, 88, 161, 104, 161, 120, 97, 128, 33, 176, 161, 225, 162, 253, 130, 246, 2, 239, 226, 247, 230, 247, 237, 247, 242, 247, 243, 247, 240, 247, 238, 239, 231, 239, 225, 243, 195, 244, 195, 248, 97, 248, 161, 200, 0, 144, 64, 128, 33, 104, 65, 88, 65, 80, 65, 80, 65, 72, 65, 72, 65, 72, 65, 64, 65, 64, 65, 64, 65, 64, 97, 72, 65, 72, 97, 72, 65, 72, 65, 72, 97, 72, 97, 80, 194, 89, 34, 105, 130, 121, 195, 130, 36, 138, 100, 146, 101, 138, 133, 138, 68, 130, 4, 113, 196, 97, 99, 89, 34, 80, 194, 72, 98, 64, 65, 64, 65, 64, 65, 56, 65, 56, 65, 64, 65, 64, 65, 64, 65, 130, 5, 113, 228, 105, 163, 89, 98, 89, 34, 88, 226, 88, 161, 96, 162, 112, 66, 128, 33, 176, 129, 226, 2, 253, 130, 246, 66, 239, 226, 247, 230, 247, 238, 247, 242, 247, 243, 247, 239, 247, 237, 239, 230, 239, 225, 235, 100, 236, 229, 240, 66, 240, 129, 192, 1, 144, 64, 120, 65, 104, 65, 88, 65, 88, 65, 80, 65, 72, 65, 72, 65, 72, 65, 72, 65, 72, 65, 72, 65, 72, 65, 72, 65, 72, 65, 72, 65, 72, 65, 72, 66, 80, 130, 88, 194, 97, 34, 105, 131, 121, 195, 138, 68, 146, 100, 146, 132, 146, 100, 146, 100, 130, 36, 113, 196, 97, 131, 89, 34, 80, 162, 72, 97, 64, 97, 64, 65, 64, 65, 56, 65, 56, 65, 56, 65, 64, 65, 64, 65, 130, 37, 113, 228, 105, 131, 97, 99, 89, 2, 88, 194, 88, 162, 104, 129, 120, 65, 136, 33, 176, 161, 225, 226, 245, 162, 254, 162, 247, 225, 247, 230, 247, 238, 247, 243, 247, 243, 247, 239, 247, 238, 239, 231, 239, 226, 235, 100, 244, 227, 248, 34, 240, 97, 192, 0, 144, 96, 128, 65, 104, 65, 88, 65, 88, 65, 80, 65, 80, 65, 72, 65, 72, 65, 72, 65, 72, 65, 72, 65, 80, 65, 80, 65, 80, 65, 80, 65, 80, 65, 80, 65, 88, 130, 96, 226, 105, 34, 113, 131, 121, 195, 138, 68, 146, 132, 146, 133, 146, 133, 146, 100, 130, 36, 121, 196, 105, 163, 89, 34, 72, 97, 72, 97, 64, 65, 64, 65, 64, 65, 56, 65, 56, 65, 56, 65, 64, 65, 64, 65, 122, 36, 114, 4, 97, 68, 89, 67, 89, 2, 88, 194, 88, 193, 96, 32, 112, 64, 136, 1, 184, 129, 226, 35, 245, 163, 246, 195, 239, 226, 247, 231, 247, 238, 247, 243, 247, 243, 247, 238, 247, 237, 239, 231, 247, 226, 244, 35, 244, 164, 240, 66, 240, 129, 192, 0, 144, 96, 120, 32, 104, 64, 96, 65, 88, 65, 88, 65, 80, 65, 80, 65, 80, 65, 80, 65, 80, 65, 80, 65, 80, 65, 88, 65, 88, 65, 88, 65, 88, 65, 88, 65, 88, 130, 96, 226, 105, 66, 121, 163, 129, 227, 138, 100, 146, 133, 154, 132, 154, 132, 146, 101, 138, 68, 121, 195, 105, 130, 97, 2, 80, 97, 72, 97, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 114, 36, 105, 228, 89, 36, 89, 67, 89, 2, 88, 194, 88, 162, 88, 129, 104, 65, 136, 1, 184, 161, 226, 2, 245, 226, 246, 194, 247, 226, 247, 232, 247, 238, 247, 243, 247, 243, 247, 237, 247, 236, 239, 230, 239, 32, 243, 33, 252, 98, 248, 33, 240, 97, 192, 0, 144, 64, 128, 65, 112, 65, 96, 65, 96, 65, 96, 65, 88, 65, 88, 65, 88, 65, 88, 65, 88, 65, 88, 65, 88, 65, 88, 65, 96, 65, 96, 65, 96, 65, 96, 97, 96, 98, 96, 226, 113, 34, 129, 163, 138, 4, 146, 68, 154, 133, 154, 133, 154, 133, 154, 101, 146, 68, 121, 195, 105, 98, 97, 2, 80, 129, 72, 129, 64, 97, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 106, 4, 97, 227, 89, 100, 81, 67, 81, 2, 88, 194, 88, 193, 88, 97, 112, 65, 144, 33, 184, 129, 226, 2, 245, 226, 246, 225, 239, 225, 247, 232, 247, 238, 247, 242, 247, 242, 247, 237, 247, 234, 239, 228, 239, 131, 235, 69, 236, 36, 240, 66, 240, 65, 216, 1, 160, 65, 128, 0, 120, 64, 112, 65, 112, 65, 112, 65, 112, 65, 112, 65, 112, 97, 120, 65, 104, 97, 96, 97, 96, 97, 96, 65, 88, 33, 88, 65, 96, 65, 88, 33, 96, 161, 104, 225, 137, 66, 153, 66, 153, 227, 162, 37, 154, 133, 162, 165, 154, 133, 154, 133, 146, 36, 129, 227, 105, 130, 88, 225, 72, 97, 64, 97, 64, 97, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 122, 5, 105, 229, 97, 132, 89, 35, 80, 227, 88, 194, 88, 162, 88, 130, 112, 33, 152, 1, 184, 161, 226, 98, 253, 225, 246, 193, 239, 226, 247, 232, 247, 236, 247, 239, 247, 242, 247, 236, 247, 233, 239, 165, 247, 130, 250, 227, 251, 194, 248, 65, 240, 65, 200, 65, 160, 33, 144, 65, 128, 33, 128, 65, 128, 33, 136, 33, 136, 65, 136, 33, 136, 33, 136, 32, 144, 32, 152, 32, 160, 33, 160, 33, 160, 1, 168, 0, 168, 1, 168, 33, 168, 1, 176, 162, 185, 66, 177, 131, 178, 4, 178, 68, 170, 133, 170, 133, 162, 165, 154, 133, 146, 36, 121, 195, 105, 130, 88, 194, 80, 161, 72, 129, 64, 97, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 122, 5, 106, 37, 89, 100, 89, 35, 88, 227, 88, 162, 88, 130, 88, 162, 112, 33, 152, 33, 192, 129, 235, 162, 253, 194, 246, 130, 239, 227, 247, 233, 247, 238, 247, 236, 239, 231, 239, 230, 247, 232, 247, 231, 247, 5, 242, 100, 243, 195, 224, 195, 224, 194, 224, 98, 184, 33, 144, 0, 136, 32, 136, 0, 136, 0, 136, 1, 144, 1, 152, 1, 152, 33, 152, 33, 160, 65, 168, 65, 168, 98, 176, 98, 184, 98, 192, 98, 192, 98, 192, 130, 200, 98, 200, 162, 208, 226, 200, 66, 193, 161, 176, 196, 161, 229, 162, 101, 162, 102, 154, 133, 137, 228, 121, 131, 97, 66, 88, 193, 80, 193, 72, 97, 64, 97, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 114, 37, 105, 229, 89, 100, 89, 35, 88, 194, 88, 162, 88, 129, 88, 129, 112, 33, 152, 1, 192, 129, 242, 161, 253, 193, 254, 65, 247, 227, 247, 232, 247, 233, 239, 232, 247, 234, 239, 229, 239, 225, 238, 162, 246, 131, 251, 67, 243, 163, 241, 98, 224, 227, 224, 98, 232, 98, 232, 98, 224, 130, 224, 130, 216, 163, 216, 163, 208, 195, 208, 163, 208, 195, 200, 195, 200, 195, 200, 195, 200, 195, 200, 195, 200, 195, 208, 163, 208, 194, 217, 2, 225, 66, 241, 98, 241, 129, 249, 97, 249, 224, 233, 32, 194, 1, 161, 226, 162, 99, 154, 36, 137, 227, 113, 66, 97, 2, 80, 161, 72, 161, 72, 97, 72, 97, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 113, 229, 97, 197, 89, 100, 89, 35, 88, 226, 88, 162, 88, 129, 88, 129, 112, 65, 144, 33, 200, 161, 252, 32, 253, 33, 255, 76, 255, 237, 247, 227, 239, 229, 247, 234, 247, 232, 239, 226, 239, 161, 237, 162, 246, 133, 233, 234, 236, 72, 224, 195, 218, 3, 216, 195, 217, 131, 233, 130, 233, 227, 225, 195, 226, 35, 217, 196, 227, 195, 234, 99, 226, 228, 227, 165, 227, 133, 227, 165, 228, 5, 236, 101, 236, 133, 245, 132, 252, 195, 253, 162, 252, 65, 253, 164, 251, 131, 252, 1, 250, 0, 248, 106, 233, 42, 184, 3, 153, 228, 145, 228, 129, 131, 105, 0, 96, 225, 80, 97, 80, 129, 72, 97, 72, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 113, 197, 97, 196, 89, 99, 89, 34, 88, 194, 88, 162, 88, 129, 104, 129, 128, 33, 144, 1, 200, 225, 250, 65, 252, 224, 253, 160, 255, 128, 247, 225, 239, 226, 239, 224, 239, 224, 239, 96, 239, 64, 245, 192, 253, 196, 254, 72, 252, 71, 251, 131, 250, 226, 251, 129, 251, 161, 251, 193, 252, 2, 252, 98, 252, 162, 253, 66, 253, 162, 253, 226, 254, 34, 254, 66, 254, 97, 254, 160, 246, 225, 246, 225, 246, 224, 254, 192, 254, 192, 254, 96, 254, 64, 253, 128, 253, 96, 251, 192, 252, 64, 249, 224, 250, 0, 232, 224, 177, 97, 145, 162, 137, 194, 113, 33, 96, 193, 88, 161, 80, 129, 72, 97, 72, 97, 72, 65, 72, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 113, 229, 97, 164, 89, 99, 89, 2, 88, 194, 88, 162, 88, 162, 88, 33, 112, 64, 160, 65, 216, 161, 250, 128, 252, 65, 255, 141, 254, 13, 247, 192, 247, 193, 247, 227, 247, 165, 247, 2, 237, 194, 246, 199, 255, 76, 254, 136, 253, 194, 254, 232, 253, 200, 254, 67, 254, 36, 254, 99, 254, 163, 255, 1, 247, 64, 247, 98, 247, 194, 247, 224, 247, 225, 247, 229, 247, 231, 247, 231, 247, 230, 247, 230, 247, 231, 247, 231, 247, 230, 247, 231, 247, 232, 247, 105, 255, 75, 255, 148, 252, 175, 252, 225, 250, 193, 240, 97, 217, 1, 168, 1, 137, 97, 120, 161, 104, 193, 96, 97, 88, 97, 80, 65, 72, 97, 72, 65, 72, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 113, 228, 105, 163, 97, 98, 89, 34, 88, 226, 88, 194, 80, 161, 96, 129, 112, 65, 144, 33, 208, 96, 249, 97, 251, 0, 251, 96, 253, 224, 254, 0, 254, 64, 253, 192, 253, 162, 245, 99, 246, 35, 253, 2, 253, 34, 253, 129, 253, 98, 245, 227, 246, 161, 246, 224, 246, 129, 247, 33, 247, 224, 247, 224, 239, 224, 239, 224, 239, 224, 239, 224, 239, 226, 239, 228, 239, 228, 239, 229, 239, 229, 239, 231, 239, 232, 239, 232, 239, 230, 239, 228, 239, 225, 238, 224, 247, 0, 253, 96, 254, 97, 252, 1, 250, 224, 250, 64, 249, 1, 216, 96, 160, 160, 128, 225, 112, 129, 104, 97, 88, 65, 80, 65, 72, 65, 72, 65, 72, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 113, 228, 105, 131, 97, 67, 89, 34, 80, 226, 80, 194, 80, 162, 80, 65, 96, 129, 112, 1, 176, 65, 240, 70, 250, 39, 252, 77, 252, 76, 255, 104, 253, 233, 255, 33, 254, 98, 254, 132, 253, 164, 254, 130, 253, 225, 247, 69, 246, 165, 247, 193, 247, 227, 247, 228, 247, 230, 247, 236, 247, 236, 247, 235, 247, 236, 247, 240, 247, 242, 247, 241, 247, 241, 247, 241, 247, 242, 247, 242, 247, 240, 247, 239, 247, 239, 247, 240, 247, 241, 247, 236, 239, 227, 239, 224, 247, 130, 247, 101, 254, 100, 250, 193, 252, 66, 232, 163, 234, 98, 240, 98, 216, 65, 152, 0, 112, 129, 96, 1, 88, 65, 88, 33, 80, 65, 72, 65, 72, 65, 64, 65, 64, 65, 64, 65, 64, 65, 64, 65, 113, 196, 97, 99, 89, 66, 89, 34, 80, 226, 80, 194, 80, 161, 88, 129, 88, 129, 104, 97, 144, 33, 208, 0, 249, 160, 250, 96, 251, 224, 252, 128, 253, 1, 252, 193, 253, 193, 254, 163, 254, 99, 253, 192, 255, 32, 246, 224, 247, 224, 247, 227, 247, 229, 247, 230, 247, 232, 247, 234, 247, 236, 247, 238, 247, 239, 247, 240, 247, 240, 247, 241, 247, 241, 247, 242, 247, 242, 247, 243, 247, 244, 247, 245, 247, 245, 247, 244, 247, 238, 239, 231, 239, 232, 239, 229, 239, 225, 245, 225, 253, 224, 253, 128, 252, 1, 251, 161, 250, 96, 249, 224, 249, 32, 240, 0, 176, 32, 112, 64, 88, 32, 88, 65, 80, 65, 72, 65, 72, 65, 72, 65, 64, 65, 64, 65, 64, 65, 64, 65, 105, 196, 97, 67, 89, 66, 89, 34, 80, 226, 80, 162, 80, 162, 80, 161, 88, 161, 88, 1, 120, 64, 168, 65, 216, 129, 240, 65, 251, 64, 251, 33, 252, 226, 242, 230, 246, 37, 254, 192, 254, 64, 254, 64, 255, 128, 247, 225, 247, 225, 247, 227, 239, 229, 239, 230, 247, 234, 247, 240, 247, 241, 247, 240, 247, 239, 247, 240, 247, 246, 247, 247, 255, 247, 255, 248, 255, 248, 255, 247, 247, 246, 247, 245, 247, 244, 247, 241, 247, 235, 239, 233, 239, 229, 239, 224, 247, 192, 247, 33, 254, 229, 247, 36, 245, 195, 252, 67, 252, 0, 250, 228, 250, 4, 248, 104, 232, 40, 152, 0, 96, 64, 88, 0, 80, 65, 80, 65, 72, 65, 72, 65, 64, 65, 64, 65, 64, 65, 64, 65, 105, 196, 97, 132, 89, 67, 89, 34, 80, 226, 80, 162, 80, 162, 80, 161, 88, 129, 96, 193, 112, 97, 160, 193, 216, 97, 241, 97, 249, 225, 251, 194, 252, 2, 252, 192, 253, 224, 253, 224, 254, 193, 254, 129, 255, 161, 247, 161, 239, 224, 239, 227, 239, 230, 247, 233, 247, 235, 247, 236, 247, 237, 247, 239, 247, 240, 247, 242, 247, 242, 247, 242, 247, 241, 247, 240, 247, 240, 247, 240, 247, 240, 247, 240, 247, 240, 247, 239, 247, 235, 239, 228, 239, 224, 239, 1, 239, 65, 246, 32, 254, 99, 254, 132, 253, 162, 253, 64, 252, 160, 251, 160, 251, 64, 249, 96, 248, 192, 224, 0, 152, 32, 96, 96, 88, 97, 80, 65, 80, 65, 72, 65, 64, 65, 64, 65, 64, 65, 64, 65, 97, 164, 89, 100, 89, 67, 81, 3, 80, 194, 80, 162, 80, 130, 80, 130, 88, 130, 112, 33, 136, 192, 176, 65, 233, 1, 232, 162, 234, 99, 233, 66, 244, 162, 250, 1, 254, 33, 254, 225, 254, 225, 254, 160, 255, 64, 247, 192, 247, 228, 247, 229, 247, 232, 247, 233, 247, 234, 247, 240, 247, 240, 247, 240, 247, 239, 247, 239, 247, 238, 247, 239, 247, 240, 247, 242, 247, 242, 247, 241, 247, 239, 247, 237, 247, 235, 239, 233, 247, 233, 239, 229, 239, 128, 239, 128, 238, 34, 247, 37, 255, 105, 254, 232, 254, 131, 255, 104, 253, 198, 254, 139, 252, 11, 252, 128, 249, 128, 240, 65, 192, 33, 128, 0, 88, 64, 80, 33, 72, 65, 72, 65, 64, 65, 64, 65, 64, 65, 64, 65, 105, 197, 89, 132, 89, 67, 81, 3, 80, 226, 80, 162, 80, 130, 88, 130, 96, 130, 104, 97, 112, 65, 176, 64, 232, 192, 249, 192, 250, 65, 251, 225, 252, 98, 253, 97, 253, 224, 254, 161, 255, 4, 255, 71, 247, 4, 247, 97, 247, 161, 247, 224, 247, 226, 247, 226, 247, 227, 239, 228, 239, 228, 239, 228, 239, 227, 239, 227, 239, 226, 239, 226, 239, 225, 239, 224, 239, 224, 239, 224, 239, 224, 239, 224, 239, 225, 239, 224, 239, 224, 238, 67, 238, 196, 237, 99, 246, 130, 253, 97, 246, 129, 254, 128, 254, 192, 254, 192, 254, 128, 253, 64, 253, 64, 251, 0, 250, 64, 248, 224, 224, 64, 160, 64, 112, 97, 88, 65, 80, 65, 72, 65, 72, 65, 64, 65, 64, 65, 64, 65, 97, 197, 89, 132, 81, 67, 73, 3, 72, 226, 72, 162, 80, 130, 88, 98, 88, 129, 96, 1, 144, 0, 208, 98, 241, 35, 250, 36, 251, 227, 253, 0, 253, 161, 255, 67, 254, 230, 254, 198, 255, 38, 254, 231, 255, 3, 255, 99, 255, 3, 255, 2, 247, 33, 247, 64, 247, 65, 247, 97, 247, 97, 247, 160, 247, 160, 247, 160, 247, 160, 247, 192, 247, 97, 239, 99, 239, 67, 239, 36, 239, 4, 238, 227, 238, 163, 246, 100, 246, 68, 245, 230, 246, 69, 246, 197, 254, 230, 255, 69, 246, 68, 239, 161, 247, 96, 247, 128, 246, 192, 247, 133, 253, 38, 252, 32, 251, 96, 248, 64, 248, 128, 192, 0, 120, 65, 88, 65, 80, 65, 72, 65, 72, 65, 64, 65, 64, 65, 64, 97, 105, 197, 89, 132, 81, 99, 81, 35, 80, 226, 80, 162, 80, 130, 80, 161, 88, 97, 120, 32, 192, 96, 240, 192, 250, 96, 251, 96, 252, 224, 253, 96, 254, 32, 254, 229, 254, 167, 255, 5, 254, 231, 255, 8, 254, 102, 253, 129, 253, 1, 253, 2, 252, 226, 252, 226, 252, 227, 253, 35, 253, 67, 253, 35, 245, 4, 244, 228, 244, 196, 244, 196, 244, 196, 244, 228, 244, 228, 244, 196, 244, 164, 244, 132, 236, 68, 244, 36, 243, 228, 244, 99, 245, 37, 254, 232, 254, 136, 255, 36, 247, 160, 247, 229, 247, 231, 239, 225, 239, 224, 246, 128, 254, 96, 252, 32, 251, 224, 249, 192, 248, 192, 184, 32, 112, 64, 96, 65, 88, 65, 72, 65, 72, 65, 64, 97, 64, 97, 64, 97, 105, 229, 97, 132, 89, 68, 81, 35, 80, 226, 80, 162, 80, 162, 80, 1, 104, 97, 144, 33, 208, 65, 249, 73, 251, 73, 254, 106, 253, 74, 255, 193, 255, 36, 255, 5, 246, 3, 254, 227, 255, 72, 255, 41, 254, 167, 254, 5, 253, 162, 252, 227, 252, 161, 252, 225, 252, 161, 252, 194, 252, 98, 252, 130, 252, 66, 244, 35, 244, 35, 244, 67, 243, 195, 235, 3, 235, 131, 252, 66, 252, 34, 250, 226, 243, 34, 233, 2, 235, 98, 224, 195, 228, 195, 246, 67, 237, 133, 239, 36, 239, 193, 239, 226, 239, 228, 239, 229, 239, 226, 239, 225, 247, 67, 253, 129, 252, 1, 249, 97, 248, 193, 184, 64, 120, 64, 96, 1, 80, 65, 72, 65, 72, 65, 64, 97, 64, 97, 64, 97, 105, 197, 97, 133, 89, 99, 81, 34, 80, 226, 80, 194, 80, 161, 88, 129, 112, 65, 184, 65, 249, 96, 250, 128, 252, 128, 253, 0, 254, 160, 254, 224, 247, 65, 246, 193, 246, 224, 245, 193, 255, 66, 254, 134, 253, 37, 252, 226, 251, 66, 250, 66, 249, 193, 249, 161, 249, 65, 241, 33, 241, 33, 241, 33, 241, 1, 232, 193, 232, 129, 232, 97, 224, 129, 224, 97, 224, 130, 224, 98, 224, 130, 224, 98, 224, 97, 232, 161, 233, 98, 236, 35, 243, 196, 244, 195, 254, 98, 247, 66, 239, 225, 239, 225, 239, 228, 239, 227, 239, 225, 239, 225, 247, 131, 252, 131, 252, 33, 248, 193, 248, 193, 184, 0, 120, 32, 104, 65, 88, 65, 72, 65, 72, 97, 64, 97, 64, 97, 64, 97, 113, 229, 97, 133, 89, 100, 81, 35, 80, 226, 80, 194, 88, 161, 96, 1, 144, 0, 200, 129, 241, 162, 252, 64, 252, 192, 255, 104, 246, 231, 247, 225, 247, 228, 247, 229, 247, 65, 247, 66, 255, 68, 254, 164, 253, 99, 232, 195, 235, 196, 224, 196, 217, 2, 232, 98, 232, 98, 232, 161, 232, 97, 232, 65, 224, 65, 216, 65, 208, 65, 208, 97, 200, 33, 200, 65, 192, 33, 184, 33, 184, 33, 176, 65, 176, 33, 200, 161, 234, 132, 224, 196, 227, 227, 243, 195, 246, 162, 247, 224, 239, 227, 247, 232, 239, 232, 239, 232, 247, 233, 247, 231, 247, 164, 253, 66, 252, 34, 249, 98, 240, 193, 184, 0, 120, 64, 96, 65, 88, 97, 72, 65, 72, 97, 64, 97, 64, 97, 64, 97, 113, 229, 97, 164, 89, 99, 89, 35, 80, 226, 88, 193, 88, 161, 88, 97, 136, 33, 217, 33, 250, 64, 252, 0, 253, 160, 254, 160, 247, 224, 247, 230, 247, 232, 247, 230, 247, 227, 247, 96, 247, 67, 252, 163, 252, 192, 251, 128, 249, 129, 249, 97, 240, 97, 224, 33, 208, 0, 208, 0, 200, 0, 184, 0, 184, 0, 184, 1, 176, 1, 176, 1, 176, 1, 168, 1, 168, 1, 168, 1, 160, 1, 160, 1, 160, 1, 168, 129, 200, 129, 224, 194, 243, 130, 252, 226, 255, 1, 247, 224, 239, 229, 247, 238, 247, 240, 247, 239, 247, 237, 239, 229, 247, 193, 252, 130, 252, 98, 248, 129, 240, 161, 192, 32, 120, 64, 104, 65, 88, 97, 80, 65, 72, 65, 72, 97, 72, 97, 64, 97, 113, 229, 97, 132, 89, 99, 89, 35, 88, 226, 88, 194, 88, 161, 112, 1, 168, 33, 208, 162, 234, 194, 253, 0, 254, 0, 255, 130, 247, 228, 247, 229, 247, 233, 247, 233, 247, 229, 247, 196, 255, 67, 252, 130, 252, 194, 240, 97, 241, 193, 224, 65, 201, 1, 176, 1, 144, 97, 128, 97, 120, 65, 112, 1, 112, 65, 120, 129, 112, 97, 112, 33, 104, 65, 112, 97, 112, 65, 112, 65, 112, 65, 128, 33, 152, 129, 184, 33, 216, 97, 224, 130, 235, 194, 253, 194, 247, 65, 239, 225, 239, 229, 247, 239, 247, 242, 247, 241, 247, 238, 239, 229, 247, 161, 243, 195, 244, 99, 240, 98, 232, 161, 184, 32, 120, 65, 104, 97, 88, 97, 80, 65, 72, 65, 72, 65, 64, 65, 64, 97, 113, 228, 97, 163, 89, 67, 89, 2, 88, 226, 88, 193, 96, 161, 96, 97, 160, 65, 224, 129, 251, 33, 252, 129, 254, 128, 255, 96, 247, 224, 239, 225, 239, 227, 247, 233, 247, 231, 247, 225, 247, 98, 252, 98, 252, 193, 249, 65, 249, 33, 216, 32, 176, 96, 152, 129, 128, 65, 120, 65, 120, 65, 112, 65, 104, 65, 104, 65, 104, 65, 104, 65, 104, 65, 104, 65, 104, 65, 104, 65, 112, 65, 120, 65, 136, 65, 144, 33, 184, 97, 232, 162, 244, 2, 253, 67, 247, 161, 247, 226, 247, 232, 239, 234, 247, 237, 247, 241, 247, 238, 239, 230, 247, 161, 244, 34, 252, 130, 248, 65, 240, 161, 184, 33, 128, 65, 104, 65, 96, 97, 80, 97, 72, 97, 72, 65, 64, 97, 64, 97, 106, 4, 105, 132, 97, 67, 89, 2, 88, 194, 88, 162, 96, 162, 136, 1, 192, 65, 232, 97, 243, 97, 253, 65, 254, 160, 247, 224, 247, 226, 247, 234, 247, 238, 247, 235, 247, 231, 247, 227, 247, 98, 252, 99, 252, 194, 248, 225, 249, 33, 208, 0, 160, 96, 144, 97, 120, 129, 112, 65, 104, 65, 96, 65, 96, 65, 96, 65, 96, 65, 96, 65, 96, 65, 96, 65, 96, 65, 104, 65, 104, 65, 112, 65, 120, 65, 128, 1, 184, 97, 224, 130, 236, 66, 245, 131, 247, 226, 247, 227, 247, 233, 247, 240, 247, 244, 247, 240, 247, 237, 239, 230, 247, 160, 244, 130, 244, 100, 240, 98, 232, 161, 184, 33, 120, 64, 104, 97, 88, 97, 80, 97, 72, 97, 72, 97, 64, 97, 64, 97, 106, 4, 105, 132, 97, 35, 97, 3, 88, 194, 96, 194, 104, 162, 112, 97, 168, 97, 232, 193, 243, 129, 252, 225, 254, 224, 247, 224, 247, 228, 247, 236, 247, 239, 247, 237, 247, 234, 247, 228, 247, 131, 252, 3, 252, 225, 249, 0, 249, 33, 208, 32, 160, 96, 144, 129, 120, 97, 104, 97, 96, 97, 88, 65, 88, 65, 88, 97, 88, 97, 88, 97, 88, 65, 88, 65, 96, 65, 96, 65, 96, 65, 112, 65, 120, 66, 128, 33, 176, 129, 225, 2, 244, 130, 245, 195, 247, 226, 247, 228, 247, 234, 247, 241, 247, 244, 247, 240, 247, 237, 239, 231, 247, 192, 243, 162, 244, 100, 240, 66, 240, 97, 184, 33, 120, 97, 112, 97, 96, 97, 80, 97, 80, 97, 72, 97, 64, 97, 64, 97, 106, 5, 105, 164, 97, 100, 89, 35, 88, 226, 88, 194, 104, 194, 112, 65, 176, 65, 233, 1, 243, 162, 253, 161, 255, 1, 247, 224, 247, 229, 247, 237, 247, 239, 247, 238, 247, 235, 247, 227, 247, 98, 243, 228, 252, 195, 248, 129, 241, 1, 208, 32, 152, 128, 128, 129, 112, 97, 96, 66, 88, 97, 88, 97, 88, 97, 80, 97, 80, 97, 80, 97, 88, 97, 88, 65, 88, 65, 96, 65, 96, 65, 104, 65, 120, 66, 128, 1, 176, 129, 216, 226, 236, 195, 246, 3, 247, 226, 247, 230, 247, 236, 247, 241, 247, 244, 247, 240, 247, 237, 239, 230, 247, 192, 235, 66, 236, 69, 232, 99, 232, 97, 184, 33, 128, 129, 104, 129, 88, 97, 80, 129, 72, 97, 72, 97, 64, 97, 64, 97, 105, 229, 105, 164, 97, 99, 89, 67, 89, 2, 96, 193, 112, 161, 120, 97, 176, 97, 233, 66, 243, 194, 253, 98, 247, 34, 247, 226, 247, 230, 247, 238, 247, 239, 247, 239, 247, 236, 239, 228, 247, 131, 251, 196, 252, 194, 248, 98, 241, 33, 200, 32, 144, 96, 120, 97, 104, 65, 96, 65, 88, 65, 88, 65, 80, 65, 80, 97, 80, 97, 80, 97, 80, 97, 88, 65, 88, 65, 96, 65, 96, 65, 112, 65, 128, 65, 136, 1, 176, 161, 225, 130, 237, 3, 246, 99, 239, 226, 247, 231, 247, 237, 247, 242, 247, 245, 247, 241, 247, 238, 239, 231, 247, 192, 243, 162, 244, 35, 240, 66, 240, 97, 184, 65, 128, 129, 112, 129, 96, 129, 80, 129, 80, 97, 72, 97, 72, 97, 64, 97, 106, 5, 105, 164, 97, 99, 97, 67, 89, 2, 96, 194, 104, 162, 120, 65, 176, 97, 224, 194, 236, 2, 253, 131, 247, 130, 247, 227, 247, 231, 247, 239, 247, 239, 247, 238, 247, 237, 239, 197, 239, 163, 243, 133, 244, 163, 240, 130, 241, 33, 200, 32, 144, 96, 120, 33, 104, 128, 88, 97, 88, 97, 80, 97, 80, 97, 80, 97, 80, 97, 80, 97, 80, 97, 88, 97, 88, 65, 88, 65, 96, 65, 104, 0, 120, 64, 136, 1, 184, 162, 217, 131, 237, 35, 246, 195, 239, 227, 247, 232, 247, 238, 247, 243, 247, 246, 247, 242, 247, 239, 239, 230, 239, 160, 235, 194, 236, 4, 232, 131, 224, 130, 184, 65, 120, 129, 104, 129, 88, 129, 80, 129, 80, 97, 72, 97, 64, 97, 64, 97, 105, 229, 105, 164, 97, 99, 97, 67, 89, 2, 88, 161, 96, 162, 128, 66, 176, 130, 233, 162, 244, 66, 253, 226, 247, 192, 247, 226, 247, 232, 247, 240, 247, 240, 247, 238, 247, 238, 239, 230, 239, 195, 251, 227, 252, 162, 248, 65, 240, 225, 192, 32, 144, 96, 128, 97, 104, 97, 88, 97, 88, 97, 80, 97, 80, 97, 80, 97, 80, 97, 80, 97, 80, 97, 80, 97, 88, 65, 88, 65, 96, 65, 112, 65, 128, 33, 144, 1, 184, 162, 235, 98, 253, 66, 247, 34, 239, 226, 247, 233, 247, 238, 247, 243, 247, 246, 247, 242, 247, 238, 239, 230, 247, 160, 243, 129, 244, 3, 240, 66, 232, 161, 184, 65, 120, 128, 104, 97, 88, 97, 80, 97, 72, 97, 72, 97, 64, 97, 64, 97, 113, 229, 105, 164, 97, 131, 97, 66, 89, 34, 96, 226, 112, 130, 128, 65, 184, 97, 234, 66, 244, 99, 254, 34, 247, 225, 247, 228, 247, 233, 247, 241, 247, 241, 247, 238, 247, 238, 239, 230, 239, 194, 252, 35, 252, 99, 240, 66, 240, 193, 192, 0, 136, 96, 120, 97, 96, 129, 88, 97, 88, 97, 80, 97, 80, 97, 80, 97, 80, 97, 80, 97, 80, 97, 80, 97, 88, 97, 88, 65, 96, 65, 104, 0, 128, 32, 152, 33, 184, 161, 218, 195, 237, 163, 247, 129, 247, 226, 247, 234, 247, 238, 247, 243, 247, 245, 247, 241, 247, 238, 239, 229, 239, 98, 235, 164, 235, 196, 232, 99, 232, 193, 176, 32, 112, 128, 96, 97, 88, 97, 80, 97, 72, 97, 64, 97, 64, 97, 64, 97, 114, 4, 105, 164, 105, 131, 97, 67, 97, 2, 112, 194, 120, 162, 136, 65, 176, 129, 225, 226, 244, 195, 246, 35, 247, 226, 247, 229, 247, 234, 247, 236, 247, 237, 247, 238, 247, 238, 239, 230, 239, 194, 251, 195, 252, 66, 248, 98, 240, 129, 192, 33, 136, 129, 120, 97, 104, 97, 88, 97, 88, 97, 80, 97, 80, 97, 80, 97, 80, 97, 80, 97, 80, 97, 80, 97, 88, 97, 88, 65, 96, 65, 112, 65, 136, 1, 152, 33, 184, 194, 218, 99, 246, 2, 255, 160, 247, 226, 247, 235, 247, 239, 247, 243, 247, 245, 247, 241, 247, 239, 239, 230, 239, 129, 235, 35, 235, 164, 232, 66, 232, 193, 168, 32, 104, 128, 96, 97, 88, 129, 72, 97, 72, 97, 64, 97, 64, 97, 56, 97, 114, 5, 113, 196, 105, 132, 105, 99, 97, 35, 97, 2, 112, 130, 136, 33, 184, 97, 234, 2, 245, 2, 246, 67, 247, 226, 247, 230, 247, 236, 247, 241, 247, 242, 247, 239, 247, 236, 239, 229, 239, 98, 244, 4, 244, 35, 240, 194, 240, 97, 192, 32, 136, 129, 112, 129, 96, 129, 88, 97, 88, 97, 80, 97, 80, 97, 80, 97, 80, 97, 80, 97, 80, 97, 80, 97, 88, 97, 88, 65, 96, 65, 96, 65, 120, 1, 160, 33, 192, 162, 218, 195, 246, 66, 247, 192, 247, 226, 247, 236, 247, 241, 247, 243, 247, 245, 247, 241, 247, 238, 239, 229, 239, 65, 234, 227, 227, 100, 232, 98, 224, 161, 160, 0, 104, 128, 88, 129, 80, 129, 72, 97, 72, 97, 64, 97, 64, 97, 64, 97, 114, 6, 113, 197, 105, 132, 105, 99, 97, 66, 96, 194, 112, 98, 136, 33, 184, 129, 234, 66, 253, 66, 254, 66, 247, 226, 247, 231, 247, 237, 247, 242, 247, 243, 247, 239, 247, 236, 239, 229, 247, 96, 251, 162, 251, 226, 248, 161, 240, 65, 192, 65, 136, 129, 120, 97, 96, 97, 88, 97, 88, 97, 80, 97, 80, 97, 80, 97, 80, 97, 80, 97, 80, 65, 88, 65, 88, 65, 88, 65, 96, 65, 96, 65, 120, 1, 168, 64, 192, 194, 218, 195, 246, 98, 247, 160, 247, 226, 247, 236, 247, 241, 247, 243, 247, 245, 247, 241, 247, 238, 239, 230, 239, 65, 242, 226, 243, 35, 240, 66, 224, 97, 160, 32, 104, 96, 96, 97, 80, 129, 72, 97, 72, 97, 64, 97, 64, 97, 64, 97, 122, 6, 113, 197, 105, 132, 105, 99, 97, 66, 96, 161, 112, 97, 144, 1, 192, 97, 234, 130, 253, 98, 246, 68, 239, 227, 247, 232, 247, 238, 247, 242, 247, 242, 247, 239, 247, 235, 239, 228, 239, 98, 235, 100, 235, 228, 240, 226, 240, 65, 192, 96, 136, 129, 112, 97, 96, 97, 88, 97, 88, 97, 88, 97, 80, 97, 80, 97, 80, 97, 80, 97, 88, 65, 88, 65, 88, 65, 96, 65, 96, 65, 96, 33, 128, 0, 168, 64, 192, 161, 227, 67, 246, 98, 247, 160, 239, 225, 247, 236, 247, 242, 247, 244, 247, 242, 247, 237, 247, 235, 247, 234, 247, 7, 243, 99, 234, 195, 232, 98, 216, 129, 152, 64, 104, 96, 96, 97, 80, 129, 72, 97, 64, 97, 64, 97, 64, 97, 64, 97, 130, 38, 113, 229, 113, 132, 105, 67, 97, 34, 96, 225, 112, 65, 144, 33, 184, 129, 234, 194, 253, 130, 246, 67, 239, 227, 247, 233, 247, 238, 247, 241, 247, 242, 247, 238, 247, 235, 239, 195, 247, 130, 243, 3, 244, 2, 248, 129, 248, 128, 192, 96, 128, 97, 112, 97, 96, 97, 88, 97, 88, 97, 88, 97, 88, 97, 80, 97, 88, 97, 88, 65, 88, 65, 88, 65, 96, 65, 96, 65, 96, 65, 104, 65, 128, 33, 168, 33, 192, 161, 227, 98, 254, 97, 255, 160, 247, 226, 247, 235, 247, 241, 247, 244, 247, 242, 247, 237, 247, 236, 247, 101, 246, 193, 252, 65, 250, 97, 240, 33, 216, 129, 152, 64, 104, 96, 96, 97, 80, 97, 72, 97, 64, 97, 64, 97, 64, 97, 64, 65, 138, 38, 121, 229, 113, 132, 105, 67, 105, 3, 96, 226, 120, 66, 152, 33, 192, 129, 243, 65, 253, 193, 246, 67, 239, 228, 247, 234, 247, 239, 247, 241, 247, 239, 247, 235, 247, 234, 247, 230, 247, 101, 242, 227, 243, 194, 248, 33, 240, 129, 184, 96, 128, 97, 112, 97, 96, 97, 88, 97, 88, 65, 88, 65, 88, 65, 88, 65, 88, 65, 88, 65, 96, 65, 96, 65, 96, 65, 96, 65, 104, 65, 112, 65, 136, 1, 168, 65, 192, 162, 228, 2, 254, 97, 247, 65, 239, 227, 247, 235, 247, 240, 247, 242, 247, 243, 247, 237, 247, 233, 247, 204, 254, 138, 242, 132, 234, 67, 232, 66, 208, 97, 144, 64, 104, 129, 88, 97, 80, 97, 72, 97, 64, 97, 64, 97, 64, 97, 64, 97, 138, 38, 121, 229, 113, 164, 105, 67, 104, 226, 96, 226, 120, 34, 160, 33, 192, 129, 235, 2, 253, 225, 246, 98, 247, 228, 247, 234, 247, 238, 247, 242, 247, 242, 247, 237, 247, 231, 239, 97, 247, 66, 250, 130, 251, 130, 248, 33, 240, 129, 176, 64, 120, 97, 112, 97, 104, 97, 96, 65, 96, 65, 96, 97, 96, 65, 96, 97, 96, 97, 96, 97, 96, 65, 104, 97, 104, 65, 104, 97, 112, 97, 120, 97, 144, 1, 184, 65, 200, 161, 235, 130, 254, 129, 247, 1, 239, 229, 247, 236, 247, 237, 239, 233, 239, 234, 247, 235, 239, 229, 238, 129, 246, 99, 251, 162, 242, 2, 224, 34, 200, 64, 144, 161, 104, 129, 88, 97, 80, 97, 72, 97, 72, 97, 64, 97, 64, 97, 64, 65, 130, 37, 121, 228, 113, 164, 105, 67, 96, 226, 96, 194, 120, 33, 160, 33, 192, 129, 235, 66, 253, 162, 254, 162, 247, 227, 247, 232, 247, 237, 247, 241, 247, 241, 247, 234, 247, 230, 247, 168, 254, 232, 242, 163, 243, 98, 240, 66, 224, 129, 192, 1, 152, 129, 120, 64, 112, 96, 104, 97, 112, 65, 112, 97, 112, 65, 112, 65, 120, 65, 112, 33, 96, 97, 104, 129, 104, 65, 104, 33, 112, 97, 144, 1, 192, 225, 208, 130, 217, 35, 234, 226, 254, 98, 246, 193, 239, 227, 247, 231, 239, 228, 239, 230, 239, 233, 239, 230, 239, 228, 238, 3, 246, 36, 241, 67, 225, 195, 216, 34, 184, 129, 136, 97, 104, 161, 96, 129, 88, 129, 80, 129, 72, 129, 64, 97, 64, 97, 64, 97, 129, 229, 121, 228, 113, 163, 97, 98, 97, 1, 96, 193, 120, 33, 168, 33, 200, 193, 235, 34, 253, 130, 254, 162, 247, 226, 247, 233, 247, 238, 247, 235, 247, 235, 247, 235, 247, 231, 246, 131, 254, 193, 251, 161, 251, 1, 248, 33, 232, 65, 176, 129, 136, 97, 136, 97, 128, 33, 120, 65, 120, 65, 128, 97, 128, 97, 128, 65, 128, 33, 128, 65, 144, 33, 152, 1, 160, 0, 160, 1, 168, 1, 193, 1, 216, 65, 225, 2, 225, 66, 235, 194, 254, 66, 254, 194, 239, 225, 247, 231, 247, 236, 247, 234, 247, 233, 247, 231, 247, 227, 245, 160, 254, 33, 250, 193, 241, 161, 216, 33, 184, 96, 136, 225, 104, 161, 96, 161, 88, 161, 80, 129, 72, 129, 72, 129, 64, 97, 64, 97, 130, 5, 121, 228, 113, 195, 97, 98, 97, 33, 96, 225, 120, 33, 168, 33, 208, 225, 243, 130, 253, 98, 254, 162, 247, 227, 247, 233, 247, 238, 247, 236, 239, 232, 239, 229, 247, 229, 255, 75, 254, 106, 249, 195, 243, 2, 224, 162, 208, 162, 200, 33, 168, 65, 136, 0, 136, 32, 160, 33, 160, 1, 136, 0, 136, 32, 144, 32, 152, 32, 152, 32, 168, 64, 176, 64, 184, 64, 192, 65, 200, 97, 208, 130, 225, 2, 216, 195, 228, 132, 252, 164, 254, 66, 246, 131, 239, 162, 239, 226, 247, 231, 247, 234, 239, 229, 239, 225, 247, 65, 255, 108, 253, 205, 249, 225, 249, 193, 224, 130, 192, 194, 144, 65, 112, 225, 104, 225, 88, 193, 80, 193, 80, 193, 72, 129, 64, 129, 64, 97, 130, 6, 122, 5, 105, 163, 97, 98, 97, 33, 88, 129, 112, 33, 168, 33, 217, 33, 251, 97, 253, 65, 254, 129, 247, 226, 247, 233, 247, 237, 247, 234, 247, 233, 239, 228, 247, 192, 245, 96, 254, 35, 251, 34, 250, 161, 249, 34, 240, 130, 232, 33, 232, 65, 240, 65, 240, 65, 240, 65, 240, 65, 232, 65, 232, 97, 232, 97, 232, 97, 224, 97, 224, 130, 224, 98, 224, 129, 224, 130, 224, 162, 233, 66, 233, 130, 244, 99, 243, 197, 246, 38, 254, 38, 254, 195, 247, 192, 247, 228, 247, 231, 247, 229, 247, 229, 247, 130, 247, 32, 252, 161, 253, 97, 249, 225, 249, 193, 208, 97, 169, 1, 145, 34, 129, 34, 105, 34, 97, 33, 89, 1, 80, 225, 72, 161, 72, 129, 64, 97, 138, 38, 122, 37, 113, 195, 97, 33, 89, 33, 88, 65, 120, 33, 168, 33, 217, 65, 252, 1, 253, 96, 254, 96, 247, 226, 247, 228, 247, 230, 247, 232, 247, 230, 239, 226, 247, 32, 244, 225, 254, 2, 224, 195, 227, 131, 224, 195, 225, 163, 224, 195, 225, 34, 232, 129, 233, 98, 241, 34, 241, 226, 242, 130, 242, 98, 242, 66, 251, 130, 242, 194, 244, 2, 252, 34, 251, 194, 252, 34, 252, 34, 252, 34, 252, 130, 253, 66, 254, 69, 255, 131, 255, 70, 255, 42, 247, 228, 247, 225, 247, 230, 247, 234, 247, 197, 247, 193, 253, 192, 254, 204, 252, 204, 240, 98, 241, 194, 224, 33, 177, 130, 137, 98, 121, 97, 113, 97, 105, 97, 97, 97, 89, 33, 80, 225, 72, 161, 64, 97, 130, 102, 122, 37, 113, 227, 97, 66, 89, 34, 88, 161, 120, 33, 176, 33, 225, 97, 251, 33, 253, 128, 254, 32, 247, 192, 247, 227, 247, 230, 239, 227, 239, 226, 239, 2, 246, 224, 252, 160, 253, 194, 253, 101, 251, 133, 250, 130, 250, 33, 250, 129, 250, 97, 250, 225, 251, 32, 251, 32, 251, 33, 251, 193, 252, 34, 252, 97, 252, 129, 252, 225, 253, 32, 253, 64, 253, 96, 253, 128, 253, 192, 253, 224, 254, 0, 254, 32, 254, 98, 255, 72, 255, 41, 255, 169, 247, 233, 247, 233, 247, 234, 247, 168, 246, 197, 253, 98, 253, 161, 251, 64, 251, 0, 249, 128, 249, 161, 209, 96, 161, 193, 145, 163, 137, 163, 113, 130, 105, 98, 105, 66, 97, 33, 89, 1, 72, 129, 64, 129, 130, 70, 122, 5, 113, 196, 97, 99, 89, 34, 88, 225, 120, 33, 184, 65, 225, 129, 251, 96, 253, 128, 255, 75, 254, 139, 247, 224, 247, 227, 247, 228, 247, 129, 246, 224, 245, 163, 246, 100, 253, 227, 250, 171, 253, 206, 251, 69, 252, 97, 253, 32, 253, 96, 253, 96, 253, 193, 254, 165, 254, 37, 254, 98, 254, 130, 254, 192, 255, 0, 255, 66, 255, 100, 255, 133, 247, 132, 247, 164, 247, 131, 247, 132, 247, 132, 255, 134, 255, 135, 255, 70, 255, 169, 247, 137, 255, 233, 247, 202, 247, 169, 255, 103, 254, 66, 254, 192, 252, 128, 252, 66, 250, 98, 248, 102, 249, 167, 208, 1, 161, 225, 145, 227, 129, 195, 121, 195, 121, 131, 105, 164, 97, 67, 89, 2, 80, 194, 72, 129, 130, 39, 122, 37, 105, 163, 97, 131, 97, 34, 88, 161, 120, 65, 176, 33, 217, 129, 250, 161, 253, 128, 252, 224, 254, 160, 254, 160, 247, 64, 254, 160, 254, 224, 245, 65, 245, 195, 253, 65, 253, 66, 252, 226, 252, 192, 253, 64, 253, 128, 253, 224, 254, 0, 254, 64, 254, 160, 254, 192, 246, 224, 247, 0, 247, 96, 247, 160, 247, 192, 247, 224, 247, 224, 239, 224, 239, 224, 239, 224, 239, 225, 247, 226, 247, 225, 239, 128, 239, 128, 238, 129, 246, 161, 255, 65, 255, 134, 247, 105, 255, 6, 254, 2, 253, 1, 252, 98, 251, 224, 250, 96, 250, 32, 249, 32, 233, 161, 185, 193, 154, 2, 146, 4, 138, 36, 129, 228, 121, 195, 105, 163, 97, 99, 89, 34, 80, 162, 72, 130, 130, 70, 122, 5, 113, 228, 97, 162, 89, 34, 88, 162, 120, 65, 168, 33, 217, 129, 251, 192, 252, 224, 254, 237, 253, 141, 255, 66, 254, 99, 254, 227, 245, 196, 246, 98, 254, 160, 254, 98, 254, 100, 255, 4, 254, 99, 254, 130, 254, 193, 255, 69, 255, 69, 247, 194, 247, 162, 247, 193, 247, 225, 247, 227, 247, 230, 247, 234, 247, 236, 247, 236, 247, 237, 247, 238, 247, 240, 247, 242, 247, 242, 247, 237, 247, 234, 247, 232, 239, 193, 247, 192, 247, 192, 247, 132, 255, 139, 247, 108, 254, 102, 255, 35, 252, 227, 241, 225, 243, 33, 248, 227, 249, 67, 240, 68, 209, 133, 160, 226, 137, 227, 146, 36, 138, 4, 130, 4, 113, 196, 105, 131, 97, 35, 89, 2, 80, 194, 72, 130, 130, 71, 122, 37, 113, 228, 89, 99, 81, 34, 80, 194, 112, 65, 168, 33, 217, 96, 249, 192, 251, 224, 252, 0, 253, 64, 253, 128, 253, 192, 254, 163, 254, 133, 254, 231, 254, 199, 254, 231, 254, 132, 254, 193, 254, 225, 247, 34, 247, 68, 247, 195, 247, 227, 247, 229, 247, 232, 247, 233, 247, 235, 247, 236, 247, 236, 247, 236, 247, 236, 247, 236, 247, 236, 247, 236, 247, 235, 247, 234, 247, 235, 247, 235, 247, 233, 239, 227, 239, 225, 247, 230, 247, 233, 247, 73, 247, 8, 254, 3, 253, 224, 252, 32, 251, 224, 250, 224, 250, 32, 249, 64, 249, 64, 225, 32, 177, 193, 137, 226, 130, 3, 130, 3, 130, 36, 121, 227, 105, 227, 97, 131, 89, 35, 81, 2, 72, 162, 64, 97, 130, 6, 122, 69, 113, 196, 89, 66, 81, 34, 88, 66, 120, 65, 168, 33, 225, 64, 252, 64, 250, 64, 252, 0, 252, 160, 253, 96, 253, 160, 254, 226, 254, 101, 254, 231, 255, 8, 255, 8, 255, 73, 255, 38, 247, 198, 247, 230, 247, 232, 247, 233, 247, 228, 247, 230, 247, 235, 247, 241, 247, 237, 247, 236, 247, 234, 247, 235, 247, 242, 247, 244, 247, 244, 247, 244, 247, 238, 247, 238, 247, 242, 247, 239, 239, 231, 239, 228, 247, 231, 247, 230, 247, 134, 255, 69, 254, 67, 254, 226, 252, 192, 252, 6, 251, 6, 249, 3, 249, 99, 248, 67, 233, 35, 176, 2, 137, 163, 129, 162, 121, 227, 129, 227, 121, 227, 105, 196, 97, 100, 89, 99, 81, 3, 72, 162, 64, 129, 56, 97, 130, 6, 122, 37, 105, 196, 89, 67, 81, 66, 80, 194, 88, 161, 136, 128, 217, 0, 249, 64, 250, 96, 250, 192, 251, 224, 252, 64, 252, 160, 253, 32, 253, 224, 254, 0, 254, 129, 254, 195, 255, 4, 255, 35, 247, 163, 247, 194, 247, 227, 247, 227, 247, 229, 247, 230, 247, 230, 247, 231, 247, 232, 247, 234, 247, 236, 247, 237, 247, 236, 247, 235, 247, 235, 247, 235, 247, 236, 247, 237, 247, 237, 247, 235, 247, 232, 239, 230, 247, 228, 247, 65, 246, 160, 253, 160, 253, 33, 252, 97, 251, 192, 250, 128, 250, 0, 249, 32, 249, 0, 232, 192, 177, 1, 137, 97, 121, 130, 113, 130, 113, 131, 113, 163, 105, 195, 97, 131, 97, 131, 89, 2, 72, 194, 64, 130, 56, 129, 56, 97, 138, 70, 121, 229, 105, 196, 97, 99, 89, 67, 80, 130, 88, 225, 104, 1, 160, 65, 232, 136, 249, 200, 249, 128, 251, 0, 251, 32, 252, 96, 253, 98, 253, 66, 254, 128, 254, 32, 255, 36, 254, 196, 255, 35, 247, 199, 247, 198, 247, 230, 247, 237, 247, 239, 247, 240, 247, 240, 247, 240, 247, 240, 247, 239, 247, 239, 247, 238, 247, 238, 247, 237, 247, 236, 247, 235, 247, 234, 247, 232, 247, 231, 247, 232, 247, 231, 247, 227, 247, 164, 247, 135, 253, 163, 254, 128, 252, 160, 249, 225, 251, 1, 248, 64, 249, 97, 248, 65, 216, 161, 160, 0, 121, 1, 113, 2, 105, 67, 105, 98, 97, 98, 97, 99, 97, 99, 89, 68, 81, 2, 72, 194, 64, 194, 56, 97, 56, 129, 48, 97, 138, 69, 122, 5, 105, 196, 97, 99, 89, 35, 89, 2, 80, 194, 88, 193, 120, 160, 184, 64, 241, 32, 249, 160, 250, 32, 250, 224, 251, 64, 251, 224, 252, 128, 252, 224, 253, 128, 253, 160, 254, 96, 254, 32, 255, 1, 247, 4, 247, 67, 247, 33, 247, 65, 247, 64, 247, 64, 247, 96, 247, 96, 247, 128, 247, 192, 247, 192, 247, 192, 247, 160, 247, 160, 247, 128, 247, 96, 247, 96, 247, 96, 247, 64, 247, 64, 246, 96, 254, 128, 252, 160, 253, 32, 251, 128, 251, 128, 250, 64, 249, 224, 249, 32, 248, 128, 216, 64, 152, 96, 120, 225, 104, 225, 96, 226, 97, 34, 89, 34, 89, 34, 89, 34, 81, 34, 72, 194, 72, 226, 64, 130, 56, 129, 48, 129, 48, 97, 48, 97, 130, 101, 121, 196, 105, 196, 89, 100, 89, 67, 80, 194, 73, 1, 72, 33, 88, 193, 120, 2, 176, 129, 232, 32, 249, 160, 249, 192, 250, 160, 250, 32, 251, 192, 252, 131, 252, 227, 254, 138, 254, 110, 255, 75, 254, 171, 254, 198, 254, 196, 254, 195, 254, 162, 254, 162, 254, 130, 254, 130, 254, 130, 246, 130, 246, 130, 246, 163, 246, 162, 254, 161, 254, 97, 246, 67, 246, 35, 254, 2, 253, 194, 254, 2, 253, 130, 254, 34, 252, 162, 254, 37, 251, 100, 251, 160, 250, 96, 249, 38, 249, 38, 240, 34, 208, 34, 144, 0, 104, 161, 96, 65, 88, 193, 88, 194, 81, 2, 81, 2, 81, 2, 73, 2, 64, 225, 64, 193, 64, 193, 64, 129, 56, 129, 48, 97, 48, 129, 40, 97, 130, 69, 122, 5, 105, 164, 89, 99, 89, 67, 81, 34, 80, 226, 80, 226, 80, 193, 96, 161, 128, 161, 176, 128, 233, 0, 249, 96, 250, 0, 250, 96, 251, 32, 251, 32, 252, 0, 252, 0, 252, 32, 252, 32, 252, 64, 252, 96, 252, 128, 252, 160, 252, 192, 252, 224, 253, 32, 253, 0, 252, 192, 252, 128, 252, 2, 252, 34, 252, 34, 252, 34, 252, 98, 252, 66, 252, 34, 251, 226, 251, 130, 251, 34, 250, 194, 250, 161, 250, 129, 250, 96, 250, 128, 249, 128, 249, 160, 248, 96, 240, 160, 200, 32, 144, 64, 104, 129, 88, 161, 80, 193, 72, 161, 72, 162, 72, 194, 72, 193, 64, 193, 64, 193, 64, 161, 56, 161, 56, 161, 56, 97, 48, 97, 40, 97, 40, 97, 40, 97, 130, 102, 114, 4, 105, 196, 97, 99, 81, 99, 81, 35, 80, 226, 80, 162, 80, 226, 80, 66, 96, 193, 120, 1, 168, 161, 232, 35, 249, 66, 249, 197, 250, 6, 250, 224, 250, 160, 252, 64, 251, 160, 252, 64, 252, 97, 252, 98, 252, 33, 251, 224, 252, 0, 252, 33, 251, 193, 251, 97, 251, 193, 252, 65, 252, 1, 252, 1, 251, 194, 251, 129, 251, 1, 250, 226, 250, 162, 250, 161, 250, 193, 251, 1, 250, 161, 250, 1, 250, 1, 240, 98, 241, 97, 248, 66, 248, 130, 216, 33, 168, 33, 128, 1, 96, 130, 80, 65, 72, 161, 72, 161, 72, 162, 64, 130, 64, 162, 64, 129, 64, 161, 56, 161, 56, 161, 56, 129, 56, 129, 48, 97, 48, 97, 48, 97, 40, 97, 40, 97, 122, 70, 113, 228, 105, 196, 97, 99, 89, 67, 81, 3, 80, 227, 72, 226, 80, 226, 80, 225, 80, 225, 96, 193, 120, 193, 160, 128, 225, 0, 249, 0, 249, 96, 249, 192, 250, 0, 249, 192, 249, 192, 249, 224, 249, 224, 249, 224, 249, 224, 249, 192, 249, 129, 249, 65, 241, 1, 241, 1, 241, 1, 240, 225, 248, 225, 248, 193, 240, 161, 240, 193, 240, 225, 240, 193, 240, 97, 232, 65, 240, 65, 240, 33, 240, 65, 240, 33, 240, 65, 240, 33, 232, 1, 224, 0, 184, 32, 144, 65, 112, 129, 88, 161, 80, 161, 64, 129, 64, 129, 64, 129, 64, 129, 64, 130, 64, 130, 64, 130, 56, 97, 56, 97, 56, 98, 48, 97, 48, 97, 48, 97, 48, 97, 40, 97, 40, 97, 40, 97, 122, 102, 113, 228, 105, 228, 89, 3, 81, 98, 73, 35, 72, 226, 72, 226, 72, 226, 72, 226, 80, 226, 80, 98, 88, 193, 104, 2, 144, 161, 200, 66, 233, 2, 248, 0, 249, 96, 248, 65, 249, 97, 249, 128, 249, 97, 249, 33, 249, 1, 241, 33, 232, 193, 232, 97, 224, 193, 224, 225, 216, 65, 208, 32, 200, 33, 184, 65, 176, 33, 176, 33, 168, 32, 160, 32, 152, 32, 144, 32, 144, 64, 136, 64, 128, 65, 120, 32, 112, 64, 128, 1, 128, 97, 104, 1, 104, 129, 88, 1, 80, 161, 72, 97, 64, 97, 56, 97, 64, 129, 64, 129, 64, 129, 64, 129, 56, 97, 56, 97, 56, 97, 56, 98, 48, 129, 48, 97, 48, 129, 40, 129, 40, 97, 40, 97, 40, 97, 40, 97, 130, 134, 122, 5, 106, 4, 89, 35, 81, 66, 73, 35, 72, 226, 72, 226, 72, 226, 72, 226, 72, 225, 80, 225, 81, 1, 88, 193, 96, 224, 128, 161, 168, 129, 192, 65, 200, 65, 200, 33, 200, 33, 200, 1, 192, 1, 184, 32, 184, 32, 184, 64, 184, 128, 184, 97, 176, 65, 176, 65, 176, 97, 168, 97, 160, 65, 160, 97, 152, 65, 144, 65, 136, 65, 128, 65, 128, 65, 120, 65, 120, 65, 112, 65, 104, 65, 96, 65, 88, 65, 88, 65, 88, 129, 88, 129, 88, 98, 80, 130, 72, 129, 64, 129, 64, 129, 56, 129, 56, 129, 56, 129, 56, 129, 56, 129, 56, 129, 56, 129, 56, 129, 48, 97, 48, 97, 48, 97, 48, 129, 40, 97, 48, 97, 40, 97, 40, 97, 40, 65, 130, 134, 122, 37, 114, 36, 97, 35, 81, 66, 73, 3, 72, 227, 64, 194, 64, 194, 64, 194, 72, 226, 72, 193, 72, 225, 80, 194, 80, 225, 80, 1, 97, 1, 105, 1, 96, 161, 96, 129, 96, 129, 96, 193, 96, 129, 88, 97, 88, 129, 88, 129, 88, 97, 88, 129, 88, 129, 88, 97, 88, 193, 112, 0, 112, 160, 88, 129, 88, 161, 88, 129, 80, 129, 88, 129, 104, 129, 104, 129, 96, 161, 96, 64, 80, 128, 80, 97, 80, 97, 80, 97, 80, 129, 72, 65, 72, 130, 72, 130, 64, 129, 56, 97, 56, 97, 56, 129, 56, 129, 56, 129, 56, 129, 56, 129, 56, 129, 48, 129, 48, 97, 48, 97, 48, 97, 48, 129, 40, 97, 40, 97, 40, 97, 40, 97, 40, 97, 40, 97, 138, 198, 130, 70, 113, 229, 97, 163, 89, 35, 81, 35, 72, 227, 64, 226, 64, 194, 64, 194, 64, 226, 64, 225, 64, 225, 72, 225, 72, 225, 81, 1, 80, 225, 88, 225, 88, 225, 88, 225, 96, 193, 88, 194, 88, 193, 88, 193, 88, 193, 88, 193, 88, 193, 80, 193, 80, 161, 80, 161, 80, 161, 80, 161, 80, 129, 88, 129, 80, 161, 80, 161, 80, 161, 72, 161, 72, 161, 72, 129, 72, 161, 72, 129, 72, 129, 64, 129, 64, 129, 64, 129, 64, 129, 64, 129, 64, 97, 64, 129, 56, 129, 56, 129, 56, 129, 56, 129, 56, 97, 56, 129, 56, 129, 56, 129, 48, 97, 48, 97, 48, 97, 48, 97, 48, 97, 48, 97, 40, 98, 40, 98, 40, 97, 40, 97, 40, 97, 48, 97, 138, 198, 130, 101, 114, 36, 97, 196, 89, 67, 81, 35, 72, 226, 64, 194, 64, 194, 64, 194, 64, 194, 64, 194, 64, 226, 64, 225, 72, 225, 72, 225, 72, 193, 80, 193, 80, 193, 80, 194, 80, 162, 80, 193, 80, 161, 80, 193, 80, 161, 80, 193, 80, 162, 72, 162, 72, 161, 72, 161, 72, 161, 72, 161, 72, 129, 72, 129, 72, 129, 72, 129, 72, 129, 72, 161, 72, 129, 72, 129, 64, 129, 64, 129, 64, 129, 64, 129, 64, 129, 64, 129, 64, 129, 64, 129, 64, 97, 56, 129, 56, 129, 56, 129, 56, 129, 56, 97, 56, 97, 56, 97, 56, 97, 48, 97, 48, 97, 48, 97, 48, 97, 48, 129, 40, 129, 40, 97, 40, 98, 40, 97, 40, 97, 40, 97, 40, 97, 48, 97, 138, 230, 130, 134, 114, 69, 97, 196, 89, 99, 81, 35, 72, 227, 64, 226, 64, 194, 64, 194, 64, 194, 64, 194, 64, 194, 64, 194, 64, 194, 64, 193, 72, 193, 72, 193, 72, 193, 72, 194, 72, 194, 72, 194, 72, 161, 64, 161, 64, 161, 64, 161, 72, 161, 64, 161, 64, 129, 64, 129, 64, 161, 64, 129, 64, 129, 64, 129, 64, 129, 64, 129, 64, 161, 64, 161, 64, 129, 64, 129, 64, 129, 64, 129, 56, 129, 56, 161, 56, 161, 56, 161, 56, 161, 56, 129, 56, 97, 56, 129, 56, 161, 56, 129, 56, 129, 48, 97, 48, 97, 48, 97, 48, 97, 48, 97, 48, 97, 48, 97, 48, 98, 48, 98, 48, 98, 48, 98, 40, 97, 40, 97, 40, 97, 40, 129, 40, 97, 40, 97, 146, 198, 138, 198, 114, 69, 97, 132, 89, 99, 81, 35, 73, 3, 64, 226, 64, 194, 56, 194, 56, 194, 56, 194, 56, 194, 56, 194, 64, 193, 64, 193, 64, 193, 64, 193, 72, 193, 72, 162, 72, 162, 64, 194, 64, 161, 64, 193, 64, 193, 64, 161, 64, 161, 64, 129, 64, 129, 64, 129, 64, 129, 64, 161, 64, 129, 64, 129, 64, 129, 56, 161, 56, 161, 56, 161, 56, 129, 56, 129, 56, 129, 56, 129, 56, 161, 56, 161, 56, 161, 56, 161, 56, 161, 56, 129, 56, 129, 56, 161, 56, 161, 56, 161, 48, 161, 48, 129, 48, 129, 48, 97, 48, 97, 48, 97, 48, 130, 48, 98, 48, 98, 48, 130, 48, 130, 48, 129, 48, 129, 48, 129, 48, 129, 48, 129, 48, 129, 48, 129, }; int g_image_width = 70; int g_image_height = 96; #endif
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/modules/ml/include/uai_img_data.h
C
apache-2.0
61,122
#ifndef HAAS_UAI_DEMO_DATA_H #define HAAS_UAI_DEMO_DATA_H #include "stdint.h" const int8_t conv_1_kernel[ 5 * 5 * 1 * 2 ] = { -39, -46, -128, -123, 64, -2, -37, 37, -65, 86, -20, -19, -101, 27, 4, 12, -81, 57, -45, -54, 32, 34, -13, -77, -92, 107, -1, 20, -128, -89, -6, -40, -47, -30, -6, -45, 91, 42, 127, -95, 123, 9, -18, 127, -16, 93, -86, 25, 46, 47 }; const int8_t conv_1_bias[ 2 ] = { -1, -1 }; const int8_t conv_2_kernel[ 5 * 5 * 2 * 8 ] = { -3, -34, -23, 32, -19, -25, -24, 28, 30, -52, 38, -5, -10, 4, -12, -89, 1, -12, 20, -39, -3, -128, -3, -35, -8, -35, -8, -52, 13, -19, -8, 9, 13, 18, -9, -101, -44, -28, -2, 40, 1, -30, -7, -51, -25, 37, -27, -17, -14, -24, 3, 29, -8, 25, 3, 80, 16, 111, -30, 56, -11, -18, 2, -85, 1, -23, -4, 112, -8, 127, 7, -44, -2, -16, -5, -7, -6, 44, 3, 125, -15, 12, -2, -62, -2, -36, 2, 15, -3, 83, 9, -68, 15, -78, 24, 4, 6, -20, 1, 49, -22, 97, 11, 29, 11, -8, -40, -64, -11, -25, -35, 122, -41, 37, -1, 70, -21, 42, -5, 8, -8, 58, -22, -13, -12, 95, 9, 126, -13, 21, 5, 42, 12, 26, 6, -10, -7, 92, -5, 42, 12, 31, -29, 38, -8, 4, 14, 69, -5, 105, -1, 70, 1, -128, -1, -46, 1, -102, -1, -7, -1, -28, 1, -74, 1, -47, -1, -43, 1, -92, -1, -22, -1, -5, 1, -108, -1, -117, -1, 12, -1, -128, -1, 54, -1, -94, 1, -95, -1, -127, -1, -82, -1, -114, -1, -73, -1, -47, -1, 54, -12, 9, -41, -123, -25, -54, -22, -36, -12, -63, -33, 4, 11, 46, -23, -98, -7, -29, 2, 42, -7, -122, 18, -16, 36, -72, -28, -46, -29, -23, 1, -12, -16, -61, 20, 64, 6, -27, -49, -128, -1, 90, 36, -86, 2, 33, -21, -42, -24, -50, -1, 38, 12, 104, -6, 79, 1, 16, 5, 51, -1, -24, -1, -39, 1, 44, -1, 15, -1, -9, -1, -111, 2, -92, -1, 26, -1, 23, 1, -45, -1, -128, -1, -128, -1, -118, 1, -30, -1, -35, 3, -94, 1, -39, -1, -99, 3, -46, -1, -22, -28, 30, -7, -19, -24, -63, -19, -91, 10, -15, 11, 28, 13, -92, -15, -47, -30, -9, 1, 32, -1, 127, -5, 2, 2, -6, -17, 71, -10, -30, -1, 73, -21, 23, -3, 19, 4, 116, 4, -12, -16, 87, -32, -34, 19, 38, -8, 20, -13, -11, -7, -110, -1, -128, -1, -128, -1, -128, -1, -128, -1, -53, -1, -128, -4, -122, -1, -101, -1, -97, -1, -96, -9, -81, -30, -98, -13, -20, 9, -86, 1, -84, -1, -7, -1, -44, -6, -98, -1, -94, -1, -89, -1, -13, -1, 93, -1, 110, 1, 119 }; const int8_t conv_2_bias[ 8 ] = { -1, -1, -1, -1, -1, -1, -1, -1 }; const int8_t conv_3_kernel[ 5 * 5 * 8 * 16 ] = { -94, -77, -128, 1, -62, -47, -91, -45, -22, -64, -69, 2, -64, -52, -35, 47, -75, -128, -31, -1, -69, 10, -72, -2, -79, -52, -55, -1, 22, -38, 91, 5, -94, -103, -31, -1, 26, -69, -45, -44, -112, 21, -105, 1, -95, -95, -1, -102, -26, -128, 21, -2, -30, -3, 6, -52, 47, -104, -124, 10, 22, 13, 26, 51, -5, -51, -102, -1, 94, -98, -69, 28, -66, 4, -128, -1, -74, -18, -49, 3, -121, 22, -61, -1, -5, -50, -38, 27, 50, -1, 18, 2, 41, -64, 35, -10, -70, -10, 19, -5, -42, 16, 17, -41, 16, -20, -55, -1, -61, 24, -126, -5, -19, 95, 62, 1, 5, -75, -61, 47, -3, -45, -21, -1, -13, 38, -22, -2, -9, -48, -112, 1, 95, 61, -33, 4, -75, 5, -64, -1, 1, 3, 2, -6, -52, -128, -54, 1, -69, 19, 4, -1, 45, -49, -67, 1, 45, -49, 10, -16, -125, 7, -28, -1, -5, 17, 28, -20, -1, -89, 38, 1, -91, -38, 29, 7, -38, -67, 70, -1, -45, -76, -128, -5, -22, -109, -2, 1, 63, -7, 54, 21, -51, 19, 17, -1, 38, -51, -48, 19, -30, -47, 27, -1, -14, -30, -91, -4, -1, -107, 46, -1, -25, -79, -128, 8, -76, -21, -116, 1, 2, -49, -26, -58, -64, -60, -94, -1, 1, -103, -51, 19, -19, -105, -105, 1, -68, -62, -25, -47, -70, -62, -12, 1, -22, -40, 56, -9, -56, -40, -55, -1, 11, -28, -65, 3, -95, -128, -77, 1, -7, 27, -40, -6, -16, -28, -88, 1, -25, 37, -66, -57, -63, -22, -75, 1, -26, 40, -20, -56, -7, -40, -116, -1, -56, 7, -13, -61, -83, -26, -14, -1, 14, 6, -26, 44, -14, -29, -103, 1, -14, -75, -80, -17, -32, -66, -71, 1, -45, -49, -11, -45, -79, -49, -126, -1, -49, 44, -128, 14, -74, -68, -76, -1, -5, -111, -94, -7, -77, 37, 51, -1, -19, -8, -58, -40, -57, -7, -30, 1, 1, 6, -128, -1, -16, -83, 31, 1, -1, -124, -6, -1, 28, -29, -82, 1, -31, 29, 49, -30, -128, -79, -70, 1, -1, -32, -53, 1, -121, -111, 22, 1, -18, -70, -17, 3, -19, -124, -19, -1, -5, -87, -126, 9, 40, -20, -29, 1, -80, -21, 22, -28, -21, -49, -126, -1, -28, -87, -3, 1, -31, -20, -8, -2, -2, -71, -1, -40, 22, -35, -39, -2, 3, -19, -88, -42, -22, 12, 27, -5, -2, 72, 27, -81, 12, 53, 45, -2, 1, 110, -2, -33, 4, -2, 64, -5, -19, 49, 43, -33, -26, -2, 24, 3, -4, -85, 19, 51, -43, -25, -22, 2, -7, -57, -12, 36, 2, 79, 12, -3, -6, 1, 34, 40, -16, 83, 45, 8, 1, 57, 1, 14, -28, 53, 38, -1, -7, 106, 2, 45, 5, 17, 65, 6, 8, 78, 18, 33, 1, -27, -44, 1, -26, 18, -20, -7, 4, 22, -32, 1, -26, 8, -11, -5, -11, 71, 6, 1, 2, 90, -11, -34, 4, 127, 7, -24, -1, 105, -14, -24, 2, 83, 3, -6, 5, 112, 66, 18, 5, 10, -60, -3, 8, 39, -103, 125, -4, -12, -84, 1, 1, 12, -109, 97, 1, 43, -124, -6, -20, 64, -78, 125, -5, 110, -49, -17, -28, 42, -88, -11, -17, -106, 38, -3, 3, 19, 125, 97, -27, -127, -113, 10, 1, -10, -22, 127, -14, -105, -100, -8, 12, -17, -87, 127, -20, -48, -93, 5, -6, -1, -101, 127, -1, 34, -32, 6, -1, -3, -66, 44, 14, -12, -15, -1, 1, -35, -22, -41, -3, 37, -19, -1, -4, 5, -14, -18, -15, 17, -18, -1, -2, 74, -63, -43, -3, 59, -4, -1, -1, 57, -8, -36, 14, 43, 30, -1, 1, 80, 45, -69, -6, -82, -13, -1, -5, -53, -21, 41, 1, -91, -70, 1, -1, -13, -7, 88, 1, -69, -124, 1, -15, 26, -91, 68, -11, -9, -102, 1, 1, 73, -128, 45, 1, 33, -24, 1, 1, 18, -98, -43, -18, -73, -36, -1, -2, -72, 8, -50, -10, -128, -66, 1, -2, -94, 12, 12, 10, -128, -51, -1, -7, -47, -6, 62, -5, -115, -56, -1, -1, -18, -31, 71, 11, -65, -17, -1, 2, -1, 10, 4, -9, -32, -34, -1, -1, -35, -31, -71, 9, -70, -26, 1, -1, -19, 40, -40, -1, -47, 7, -1, -1, 14, 17, 19, 7, -22, -1, 1, 1, 34, 26, 13, 18, -32, 39, -1, 1, 14, 43, 22, -7, 3, -36, -1, -1, 6, -21, -16, -32, 15, -39, -1, -1, 24, -7, -31, 1, 8, -13, -1, -1, 51, 5, 14, 3, 37, 26, -1, 1, 19, -8, 13, 3, 32, 40, 1, -1, 39, 3, -16, -18, -27, -27, 15, 5, 23, -26, -64, 13, 33, 16, -21, -60, 45, -6, -46, -69, -21, -16, 17, -18, 58, 28, -58, -2, 1, -5, 4, -58, 61, 6, -43, 6, -77, 44, -41, 2, 88, -6, -33, -61, -37, -15, -3, -27, 86, -1, 69, -38, 6, -13, -19, -6, 26, -16, 25, -3, -9, -28, 6, 3, 86, 8, -9, -37, 60, -55, -23, -28, 61, -1, -8, -28, 27, 15, -26, -27, 127, -58, -16, -2, -49, 23, 1, 2, 19, -9, 65, -17, -5, -41, 6, -45, 32, 3, 85, -33, -20, -34, 5, -26, 19, -5, 6, -16, 9, -6, -27, 19, -8, -23, -25, 5, 5, 13, -34, -3, -8, 23, -81, -34, 5, 13, 5, -6, -76, 26, -79, 3, -3, 4, -19, -6, -84, -56, -27, -5, -15, -6, 8, -8, -19, -9, 49, -54, -44, -23, 9, -16, -49, -18, 26, -8, -23, -22, -27, -3, -70, 1, -68, -33, -1, -21, 3, -13, 26, -28, -128, -6, -25, -16, -17, 20, 43, 2, -128, 1, -45, 27, 6, -68, 19, 9, -36, -27, -36, -27, -15, -28, 20, -48, -48, -56, -47, -36, 1, 16, -9, 9, -65, 1, 55, 69, -3, -1, 73, 104, -33, 1, 91, 29, 1, 3, 17, -24, -35, -1, 127, 62, 25, 1, 45, 3, -100, 1, 116, 46, 13, 2, 57, -9, -107, 1, 93, 35, 1, 2, 62, 69, -28, 4, 56, 108, -4, 1, 40, 127, 19, 1, 68, 2, 5, 1, 31, -11, -15, 1, 116, -26, 21, -2, -42, -62, -64, 1, 38, 17, -31, 1, -40, -73, -46, 1, 53, -3, 3, -1, -16, -16, -5, 1, 8, 55, -1, -14, 89, 71, -54, -1, -4, -40, 3, -10, 55, -28, -94, -1, 35, -43, -1, 2, -40, -71, -128, -1, -41, -44, 1, -1, -115, -62, -128, -1, -23, -10, 5, -1, -97, -49, -94, 1, 15, 35, -1, 3, 89, 127, -43, -1, -44, 1, 4, -16, 95, 4, -49, -1, -30, -78, -8, -10, -121, -110, -69, -1, -57, -59, -5, -1, -39, -92, -73, -1, -114, -54, 3, 1, -124, -86, -66, 6, 28, 103, -13, 2, 78, 74, 87, -2, -90, -20, -13, 8, 87, 8, 37, -1, -100, -64, -2, -16, -95, -75, 64, -1, -107, -128, -6, -1, -53, -128, 50, 1, -64, -95, 5, -1, -99, -32, 49, -18, 60, 19, -4, -18, -3, -8, -45, -5, 63, 40, 10, -6, 58, 6, -53, -7, 31, 64, 18, -2, 59, 23, -72, 21, -1, 55, -9, -2, 25, -4, -85, -8, -13, -8, -2, -15, -48, 4, -92, -19, 18, -27, -7, 16, -50, -50, 50, -1, 79, 14, -18, -12, 13, -28, 20, -25, 66, 41, 7, -25, 74, -22, -10, -19, 12, 35, 2, -19, 49, -6, -21, 12, -28, -40, -1, 10, 11, -35, -18, -6, 15, -24, -12, -29, -5, -35, 31, -15, 26, 18, -19, 19, -7, -32, 58, -6, 37, -22, 14, -7, 59, 9, 41, 4, 20, -4, -20, -19, 34, -33, 34, -28, -28, -17, 11, -16, 49, -6, 8, -8, -6, -20, -6, -12, 6, -7, 38, -26, -3, -35, -1, 11, 13, -2, 103, 10, -30, -59, -13, 5, 54, -26, 127, -21, -7, -15, -4, -10, 51, -15, 78, 10, -1, -26, -6, -25, 73, -4, 36, 7, 9, -10, 5, 2, -12, 16, 49, -27, -35, -24, 2, -21, 13, -2, 126, -17, -34, -38, -5, -12, -15, -11, 127, 8, -32, -54, 7, -14, -10, -28, 111, -18, 12, -21, -13, -11, 15, -4, 48, 5, -2, -8, 2, 10, 35, 6, 126, -28, -11, -28, 4, -27, 108, 26, 93, 10, 26, -2, -40, 1, 88, 7, 3, 3, 41, -38, -13, -5, 106, -109, -98, 5, 37, -4, -15, -2, 94, -24, -128, 10, -32, -14, 12, 7, 27, -11, 105, -17, 44, -3, -24, -11, 27, 30, 126, -8, 17, 12, -11, -56, 94, 55, 126, -47, 69, -46, -24, -5, 31, -101, -1, -9, 20, -8, -11, -68, 41, -31, -41, -33, -57, 13, -2, 27, 4, 28, -37, 26, 101, 40, -11, -33, 41, 14, 3, -33, -27, -1, -18, -16, 126, 94, 34, -22, -20, -89, -17, -38, 62, -54, 95, -19, -6, -98, 3, -32, -1, -8, -7, 24, -15, 1, 5, -46, -31, 30, -98, -11, 106, 78, -7, 18, 98, 10, -10, -9, 27, 34, 16, -17, 126, 35, 88, -28, 12, -9, -10, -14, 7, 5, 68, -2, -93, -5, -3, 10, -49, -54, 94, -8, -10, 27, -5, -4, -106, 7, 26, 34, 99, 26, -1, -9, -78, 40, 44, -1, 81, 47, -17, -8, 69, 7, 15, 8, -18, 1, -30, -9, 109, -58, 7, -16, -94, -22, -11, -20, -3, -7, 35, 1, -8, -9, 1, -1, -1, -1, -1, -1, -7, -7, 1, -1, -1, -1, 9, 1, -3, -42, -1, -1, 12, -1, 1, 1, -2, -9, 1, 1, -2, 8, -3, -1, -1, -3, 1, -3, -1, -1, -1, -1, -1, 2, 1, 1, -1, -1, -1, -3, 6, 25, 1, 1, -2, 3, 1, -1, -4, -5, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -13, 1, -1, -1, -1, -8, 1, -1, -62, -1, 1, -1, -10, -20, -1, 4, -16, 1, 1, 1, -30, -39, 1, -1, -116, 1, 1, 6, -34, -26, -10, 1, -62, 1, 1, 1, -9, -54, -8, 1, -97, -1, 1, -1, 9, -56, -15, -1, -128, -1, 1, -1, -16, 1, -1, 1, -31, -1, -1, -5, -22, -1, -17, 1, -32, 1, 1, -1, -59, 1, -38, -13, -65, -1, 1, -1, -1, 1, 24, -2, -90, -1, 1, -8, -12, 14, -9, -1, 1, -1, -1, -1, 1, -1, 1, 1, -52, 1, -1, -5, -26, 1, -1, -16, -2, -1, 1, -1, -32, 1, -3, 2, -14, 1, -1, 1, 1, 2, 1, -44, -28, 1, 1, -62, -2, -1, -1, 5, -87, -1, 1, 23, -23, 127, -1, -41, -49, 1, -1, 14, -93, 127, -8, -90, -21, 1, -2, 2, 8, 94, -7, -44, -29, -1, 5, -54, -4, -5, -12, -40, -27, -1, 2, -39, -29, -17, -2, -24, -24, -1, -1, -11, -1, 29, -4, -26, 5, 1, 1, -14, 14, 54, 1, -46, 4, -1, 1, -46, 106, 5, -3, -23, 2, 1, 2, -45, 98, -85, 6, -47, -1, 1, 1, -54, 20, -119, 1, -8, -20, 1, 1, 10, 28, -59, -5, 96, 41, 1, 1, 14, 3, -91, -1, 117, 95, -1, 1, 121, 28, -117, 1, 34, 8, -1, 1, 127, -32, -122, -9, -10, -13, 1, 1, 29, -32, -105, 1, -11, 5, 1, 1, 20, -1, 104, -1, 99, -47, 1, 1, 48, -50, 124, 2, 104, -16, -1, -1, 127, -100, 34, -1, 84, -41, -1, 1, 112, -128, -48, 1, 23, -46, 1, -1, 47, -128, -94, 1, -109, -100, 1, 1, 10, -16, 102, -4, -95, -94, 1, -1, -9, -13, 127, -6, -16, -96, 1, 1, 13, -41, 127, -5, -27, -128, 1, -1, 8, -90, 21, 1, -40, -89, -1, -1, -3, -21, -42, -8, -51, -30, -13, -6, -114, 2, -105, -42, 19, 26, -9, 25, -108, -39, -68, -8, 13, -17, -5, 1, -40, -8, -71, 16, 20, 62, -19, -29, -30, 15, -36, -8, -13, 43, -16, -12, -17, -21, -40, -38, -18, 13, -17, -5, -76, 11, -128, -10, -13, 3, -6, -16, -52, -10, -128, -5, 32, -5, 12, 9, -68, -39, -80, -24, 58, -20, -9, -10, -57, 13, -57, -2, 3, 1, 6, -22, -30, 3, -70, -12, -6, 38, -10, 10, -51, 26, -128, 6, -15, 20, -25, -6, -29, 15, -77, -6, 1, -29, 3, -19, -10, 1, -61, -32, 29, 21, 2, 16, -117, 16, -62, 15, -11, 22, 1, -22, -105, 17, -62, 16, -3, 15, 5, 10, 45, 26, -85, 5, 16, 2, -13, -25, -9, 12, -42, -9, -19, -44, 5, 4, -13, -6, -76, 6, 1, -25, -12, -1, -23, 2, -82, -1, 6, 27, 10, -34, 23, 20, -52, 21, 18, -21, -18, -1, 52, -2, -1, 10, -20, -19, -29, -30, 31, -6, 72, 5, -8, -22, -35, 16, -15, -27, 43, -34, 30, 17, -13, -22, -9, -20, 19, -26, -20, -25, -5, -26, 9, -38, 48, 10, -54, 6, -5, -1, 13, -35, -34, 1, -34, 35, 12, -36, 5, 17, -54, 25, -92, -2, -6, -2, -53, 59, -78, 3, -39, -75, 8, 5, -22, -18, -36, 23, -30, -18, -9, 9, -21, -16, -26, -17, 22, 10, -5, -13, 25, -9, 21, -16, 34, 34, 19, -9, 30, 2, -119, -24, 7, 53, 7, -7, 87, 80, -87, -4, -94, 3, 1, 17, -24, 36, -58, -6, -106, -30, -20, -7, -58, -23, 16, -20, 35, -28, 12, -16, 81, -42, -18, -3, 54, -6, -27, -26, 32, -12, -27, -24, 44, 43, -15, -28, 98, 15, -120, 18, -66, 47, 9, -2, -25, 42, -21, -8, -77, -1, -17, 1, -128, 7, 25, -16, -5, -46, -1, -51, 39, -90, 43, -16, 46, -52, 6, -20, 13, -8, 9, 9, 42, 46, 8, -41, 20, -5, -14, 16, -47, 72, 6, -8, 4, 24, -35, 1, -78, 2, 4, -12, -128, 28, 30, -39, -30, -123, -26, -28, 35, -128, 127, -66, 8, -94, 11, -27, 28, -72, 101, -42, 98, 15, 20, -11, -3, -53, 94, -53, 30, 58, 10, -27, 90, 27, -24, -3, 12, 50, 23, -6, -78, 59, -61, -1, 37, 13, -1, -1, 101, -4, -9, -1, 127, 36, -1, -1, 99, -30, -111, 1, 127, 120, 1, 1, 127, 5, -128, 1, 4, 127, -1, -1, 98, 116, -128, 1, 26, 127, 1, -1, 30, 106, -128, 1, -8, -101, 1, 1, 13, -107, -29, 1, 120, -98, 1, -1, 8, -128, -25, -1, 127, 98, -1, 1, 99, -113, 21, 1, 127, 127, -1, 1, 112, 28, -18, -1, 41, 124, 1, -1, -1, 104, -113, 1, -32, -111, 1, 1, -100, -101, 8, -1, 18, -28, -1, 1, -110, -127, 6, 1, 123, -17, -1, 1, -11, -105, -46, -1, 127, 3, -1, 1, -5, -5, -128, -1, 31, -8, 1, -1, 109, 1, -128, -1, -40, -42, 1, 1, -116, 17, -98, -1, 16, -110, -1, -1, -30, -95, -9, -1, -99, -97, -1, 1, -111, -117, -42, -1, -104, -40, -1, -1, -124, -105, -123, -1, -105, -29, 1, 1, -105, -102, -128, -1, -38, -26, -1, 1, -4, 16, -104, -1, 1, -128, -1, -1, 13, -112, -101, -1, -10, -128, -1, -1, 28, -128, -7, -2, -124, -128, 1, 1, 11, -128, -8, -1, -116, -128, -1, -1, -113, -32, -128, -4, -38, 127, -9, -36, -29, 51, -30, 42, -20, 31, -25, 17, 16, 74, 65, -21, -54, -15, -11, -11, -15, -20, -55, 20, -10, -128, -21, 5, -16, -115, -128, -5, -19, -116, -9, -35, 62, -39, -89, 25, 6, 116, -36, -36, 94, 32, -35, -8, 26, 19, -10, 15, 106, 42, 89, -49, -25, -38, -16, 8, 89, -53, 127, 32, -128, -126, -20, 47, -55, -77, 127, -5, -33, -54, -8, -1, -118, -47, 107, 28, 54, 38, -32, -28, 101, 5, 30, -6, 32, 90, -7, -47, 89, -18, 19, 9, -45, -18, -19, 23, 77, -4, 7, -10, -101, 3, -12, 15, -44, -47, -64, -16, -60, -46, -3, -6, -126, -11, 15, -43, 17, 41, 4, 38, -3, 30, 44, -17, 56, 17, -4, -19, 87, 4, 36, 25, 36, 16, -14, -28, 103, 25, -2, 16, 7, 7, -10, 1, 125, -54, -21, -1, -32, -65, -17, 16, 99, -28, 73, 1, -11, 32, 26, 5, 11, 56, 16, -3, 68, 41, -12, -17, 46, 6, 98, 14, 24, 16, -15, -18, 78, -16, 75, -7, -59, -46, -5, -38, 109, -28, 76, -36, -80, -120, -6, -26, 65, -4, 108, -128, 30, 32, 1, 34, -25, -32, 121, -28, 63, -14, -1, 89, 18, 53, -39, 36, -82, 36, -1, 38, 2, -25, 34, -56, -95, 16, -1, -80, -74, 21, -47, 23, -17, -22, 1, -121, -65, -128, -5, -46, -46, 10, -1, -5, -52, 16, -23, 13, -74, 7, 18, 35, -29, -89, -32, 100, -99, 17, 16, -70, -61, -71, 28, 1, -128, -75, 1, 41, 8, 53, 124, -128, -107, -22, -1, 20, -116, 63, -2, -93, 34, -45, 1, -38, -33, -1, 36, -65, -128, 25, 2, 1, 65, 52, -39, -90, -11, -125, 1, -70, -95, 112, -81, -8, -35, 1, 1, -13, -65, -11, -41, -2, 5, -100, -1, -74, -128, 51, -80, -72, 15, 65, 1, 62, -20, -89, -5, -36, -128, -107, 1, 16, -23, -108, -13, 23, -4, -103, 2, 19, -104, 2, -10, -28, -80, -15, 1, -25, 56, -39, -39, 82, 27, -23, -1, 11, 23, -120, 10, 97, -121, 5, 2, -36, -17, -20, 38, -25, -64, 30, 1, -80, 53, -114, 28, -39, 72, -17, -13, 21, 40, -87, 28, -54, -68, 92, 1, -51, 14, -79, 40, 97, -38, 5, -1, -16, 29, -34, -56, -10, 1, 54, -1, 4, 31, 100, -3, -12, -45, -87, -8, 6, 68, -31, -57, -4, -4, -113, -33, 1, -16, -128, -72, -9, -1, -124, -17, -16, 50, -111, -10, -2, 68, 10, 6, -15, 6, -1, 55, 12, -27, 36, -4, 2, 120, 22, 40, -8, -54, -59, -9, 2, 119, -29, 51, -16, -70, -128, 9, -13, 36, -128, 58, 1, -51, -92, -23, -29, -29, -80, 76, -4, 49, -13, 16, -13, 4, 101, 23, -9, -18, 82, -16, 13, 95, 62, 68, -17, -64, -25, -31, 21, 127, 50, 87, -21, -59, -55, -42, 1, -6, -41, 55, 18, -79, -42, -27, -37, 1, 51, -2, 4, 33, 19, 2, -15, -2, 60, -5, 10, -1, 93, -10, 1, 58, 70, -27, 3, 15, 23, -16, 3, 125, 83, -23, -10, -29, -27, -8, 1, 83, 4, -21, -11, 3, -15, -8, -3, 86, 19, 15, 9, 45, -18, 3, -11, 85, 30, 80, 18, 73, 96, -12, 30, 70, 127, -25, -4, 69, 42, -27, 16, 103, 76, -11, -5, -52, 15, -3, 13, 82, 4, 42, -12, -55, -50, -26, -4, 68, 17, 27, -1, 57, -72, -1, -3, 66, -42, 42 }; const int8_t conv_3_bias[ 16 ] = { -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1 }; const int8_t fc_1_kernel[ 1536 * 48 ] = { -55, -87, 33, -48, -102, -40, 101, -35, -86, -24, 127, -95, 127, -41, -44, 17, -33, -15, 49, 24, -115, -3, 55, -78, -104, 82, -37, -90, -54, -79, -78, 109, -99, -83, 27, -6, -73, -69, 67, -41, -92, 70, -109, 104, 26, -73, -13, -67, -93, -122, -33, 90, 11, -45, 72, -45, -76, 26, -96, -80, -43, -92, -74, 95, -87, -128, 30, 13, -89, -11, -54, -46, -17, 34, -73, -79, 20, -93, -83, 20, -18, -49, 93, 28, -95, 55, -43, -66, -10, 127, -24, -128, 6, -117, -3, 89, -104, -128, 39, 81, -49, -49, 1, -125, -126, 127, -102, -128, -4, -99, -54, 126, -40, -44, -14, -2, -90, -28, 14, -66, 7, -28, -72, 15, -8, -67, -10, 20, -76, -48, 95, -3, -19, -20, 1, -30, -105, -28, -78, -69, -8, -46, -104, -78, -120, -78, -66, -4, -26, 3, 9, -87, -87, -112, 11, -24, -39, -18, -81, 35, 2, -80, -26, 24, -77, -66, -41, -44, 10, 104, -114, 70, 43, -98, -107, 34, 9, -47, -9, 47, -128, 5, -37, -103, 127, 67, -108, 89, -66, -72, -41, 51, -79, -48, 31, 4, -77, -90, -24, -13, 87, 74, -41, 78, -31, -124, -107, -24, -24, -59, 76, -14, -83, 1, 5, -87, 30, -69, -44, 49, 3, -108, -89, 11, 78, -31, 90, -22, -67, -35, -19, -35, 59, 44, -51, 54, -89, -123, -55, 5, -80, -45, -82, 19, -86, 70, -41, -99, 7, -108, -20, 22, -51, -7, -123, -48, -49, -1, 45, -49, 59, -2, -13, -55, -110, -59, -122, -122, 20, 12, -102, -10, -128, -85, -76, -85, -122, -30, 70, -102, -128, 79, -73, 1, 41, -3, -108, 9, -46, -27, -74, 69, -95, 35, 17, -75, 31, -8, -17, 7, 54, -35, -9, 28, -49, 12, 15, 93, -128, -51, -6, -60, -60, -95, -48, -112, 45, 1, -128, 2, 28, -99, 17, 117, -128, 51, -3, -27, -49, 43, -128, -74, 31, 127, -128, -13, -27, -28, 109, 89, -12, -40, 10, -41, 31, -20, -92, -12, -59, 122, -128, 33, 7, -59, -75, 40, -89, 1, -66, 4, -57, -74, -128, 117, 17, -46, -76, 55, -93, -79, -13, 102, -49, 127, -10, -75, -90, 48, -86, -20, -98, -107, -125, 37, -82, 70, -47, -95, -23, 74, -75, -79, -128, 112, 33, -69, -126, 14, -35, -28, -128, -70, -6, -97, -99, 18, 70, -22, -128, 46, -108, -104, -40, 1, -112, 28, -60, -123, -1, -114, -22, 24, 127, -128, -17, 10, 8, -112, 79, -41, -98, 12, -4, -40, -12, 33, -2, 55, 102, -126, -4, 55, -90, -20, 6, -128, -80, -1, -55, -43, 5, 60, -115, -4, -113, -20, -60, -27, -81, -128, -2, 115, -14, 19, -27, -76, 8, -19, -35, -8, -45, -18, -19, 46, -44, -78, -8, 79, -72, -15, 39, -26, -48, 79, -110, -79, -76, -78, 68, 39, -18, 127, -31, -128, -79, -20, -15, -37, -92, -128, 8, 69, -38, -11, -35, 57, -74, -26, 75, -79, -99, 98, 31, 2, 27, 43, -14, 45, -81, -128, 31, -43, -114, -127, 23, -51, -59, 43, -2, 74, 9, -93, -68, 33, -128, -99, 27, -107, 127, -73, 92, 44, -44, 30, 26, -69, -20, -28, -20, 4, 46, -33, 28, -105, -68, -79, 30, -39, -89, -12, -9, -102, 33, -18, -128, -33, -49, -123, -93, 33, -3, -86, -20, 55, 1, -43, -20, -97, 40, 99, -48, 10, -80, -97, 13, -46, -39, -117, 89, 86, -89, 28, 28, -38, -11, -85, -114, -41, -41, -67, -73, 83, -98, -95, 60, 79, -47, -20, 60, -7, -47, -83, -110, 11, -47, -120, -27, -28, -128, 3, -28, -43, -3, 2, -11, -89, -76, -89, -128, -2, -48, -128, -55, 5, 40, 46, 3, -99, -80, -128, -31, 75, 8, -67, 4, -48, 4, 39, 47, -39, -128, -128, -51, 5, -31, -19, -59, -85, -20, 9, -98, -5, -128, -126, -92, 72, -18, -6, 4, 24, -96, 8, -128, -126, 24, -128, -79, -72, 1, 12, 46, -128, -99, -124, -38, -26, -87, -12, -27, -67, -14, -112, -73, 27, -31, -82, -92, -22, -51, -128, -7, 45, -44, -5, 4, -38, -30, -57, -87, -55, -128, -110, 41, 96, -109, 13, -24, 120, -33, 37, -87, -115, -14, -95, -118, -26, -81, -23, 68, -24, -46, -73, -14, 126, -74, 15, 46, -128, -20, -22, -101, 82, -48, -13, 1, 27, -23, -110, 31, -19, -104, 1, -17, -37, -55, -83, -33, 15, -110, -114, 10, -40, 6, 98, 9, -49, -1, 105, -77, -118, -28, -75, -107, -70, -11, -104, -128, -124, 18, -69, 90, -10, -82, 19, -90, 85, -20, -99, 9, -41, -81, -68, -87, -55, -20, -28, 3, 18, -49, 26, -128, -118, 127, -77, -79, 44, -60, -27, -96, -115, -128, -51, 28, 72, -80, -23, -8, 76, -24, -87, -48, -8, -126, -115, 17, 37, -76, -34, -34, 40, -75, -27, 20, -79, -68, -67, -23, 5, -104, -113, 3, 51, -124, -90, 1, 92, -101, -7, 26, -6, -3, -115, -78, -74, 9, -92, 34, 48, 81, -104, 9, -9, 19, -89, 2, -27, 87, -103, -128, 5, -72, -92, -77, -19, -8, -89, 4, -24, -28, -54, -54, -118, -81, -103, -102, -26, -80, -119, 33, 28, 37, -5, 81, -128, 9, -15, -10, 27, 81, -28, -54, -18, -79, -97, -120, -54, -126, -128, 37, -13, -22, -70, 9, 49, 3, -19, -128, 39, -83, 110, 8, -101, -19, -92, 17, 17, -1, -20, -83, 127, 11, -85, -38, -33, -83, 13, 7, -105, -118, -128, 5, 95, -18, -30, 73, 119, 99, -117, -83, 20, -41, -92, 6, -28, -47, -74, 15, -72, -10, 17, -43, -14, 19, -15, -82, -15, -81, 119, 6, -19, -128, -73, 87, 89, -72, -27, -83, -51, 13, -128, -93, -55, -19, -74, 8, 35, -2, -51, 4, 127, -72, -1, -23, -57, 37, -60, -98, 26, -77, -99, -51, 23, -57, 75, -23, -47, -28, -10, 37, -22, -123, -113, -45, 92, -114, -18, -30, 47, 6, -8, -9, -118, -57, -97, -120, -72, -59, -117, -66, 68, -125, -75, -33, -69, -85, -127, 69, -2, -128, -24, -76, 69, 1, -67, -51, 31, -72, -70, -72, -30, -24, -128, 4, 15, -109, -66, 6, 35, 2, -11, -68, -15, -83, 75, 1, -34, -51, 18, 74, -59, -83, -48, -47, 46, 34, -49, -68, 127, -99, -41, 28, -128, -38, -104, -8, 73, -3, 72, 9, 19, 83, -128, -34, 10, -113, 102, -12, -128, -104, -74, 7, 82, -110, -68, -76, 38, 74, -103, -70, -67, -128, 115, 7, -55, -99, -85, 6, 126, -108, 47, 54, 12, 112, -48, -44, 47, -55, 76, 5, -18, -44, -66, 73, -66, -26, -28, -46, -55, -90, -70, -18, -33, -102, -78, 9, 1, 68, -93, 30, -114, -54, -128, 2, -17, 3, -40, -128, -76, -99, -107, -95, -68, -85, -44, 95, 24, -104, -81, -48, 89, 1, -26, -18, 20, -114, -82, 26, -128, -128, 7, 127, -26, -9, -23, 69, 83, 45, -112, -20, 13, -126, -86, 70, -96, -43, -1, 26, 76, -128, 26, -15, 127, -18, 81, -128, 23, -75, 76, -44, -113, -82, -22, 15, 124, -119, -23, -39, 73, -2, 70, -22, 28, -70, 75, 13, -57, -99, -17, 66, 125, -128, 18, -17, 57, 46, -43, -125, 14, -74, 49, 72, -124, 34, -79, -39, 17, -48, -3, -48, -20, 60, -49, -15, -7, 7, 103, -5, 86, -124, -46, -24, -54, -69, -57, -45, -76, -13, -20, -98, -1, -85, -41, 6, 99, 81, -3, -43, -40, -28, -118, -20, 40, -68, -7, -78, -41, -87, -110, -45, -99, -93, -28, 24, 4, -112, 17, -69, -99, 86, -10, -12, -13, 2, -48, 79, -122, -77, -20, 37, 43, -26, -14, -85, -102, -47, -51, -89, -68, -70, -79, -6, -98, -67, -69, 46, 41, -69, -128, -46, 26, -9, -113, -51, -72, -7, 10, -44, -34, -102, -19, -110, 43, -48, 27, -81, 78, -55, -7, -44, -18, -99, -13, -24, -57, -128, -60, -37, 51, -38, -18, -31, 89, 66, -35, -37, 33, 12, 45, -51, -59, 19, -43, 124, 86, -37, 44, 45, -76, 110, -99, -69, 90, -128, 6, -30, 55, 107, -96, -4, 45, -70, 109, 6, -128, -122, 12, -125, -76, -1, -44, -34, 127, 43, -97, -72, -114, -24, -99, 90, 1, -59, 46, -70, -81, -23, 39, -34, -31, -69, -128, 103, 57, -75, -3, -33, -14, 80, -97, -1, -15, -87, 82, 51, -90, 112, -76, -2, -9, -10, -9, -68, -55, 96, -98, -15, 92, -47, -2, -2, -128, 39, -113, 30, 95, -83, -59, 46, 127, -38, -99, -128, 4, -19, 6, 54, -96, -11, 5, -66, -1, -125, 55, -14, 102, 127, 4, -99, -35, -24, -15, -57, -74, 1, -31, -40, -80, -14, -9, -8, 38, 127, -76, -38, -74, -67, -28, 69, -76, 77, 79, -14, 13, -128, 75, -54, -70, 31, -47, -66, 4, -72, 1, 55, -90, 127, 115, 70, 81, -80, 66, -107, -101, -57, -20, -128, 5, -37, -127, 5, 37, 79, -90, -70, -12, -37, -98, 10, 25, -38, 32, 4, -9, -1, -5, 31, -14, -16, 38, 31, -42, -23, -11, -19, 11, -81, 37, -9, 10, -2, 2, 31, -41, -4, 46, -41, -47, -2, -79, 5, 22, -63, -5, 4, 33, -9, -1, 5, -17, -4, 23, -17, -9, -1, -22, -5, 38, -10, -2, -9, 66, -1, 5, 5, -22, -22, -5, 2, 14, -25, 14, 14, 1, 109, 19, -5, 33, 10, 7, 25, 23, -18, -42, 18, -2, -19, 37, 1, 34, 115, -98, -23, 57, -9, -32, 19, 17, -14, -25, 5, 5, -18, 25, -11, 23, 115, -10, 18, 47, -21, -7, 2, 61, -22, -22, -2, -23, -23, 4, -11, 25, 42, -2, 9, 18, -17, -21, -5, 23, -10, 127, 2, -11, -18, -2, 14, 7, -30, -18, -5, -14, 26, -2, 16, 4, -22, 33, -37, -39, 4, -23, -5, 22, -51, 82, -14, -18, 10, -17, 37, 33, -7, 22, -37, -114, 5, -32, 17, -2, -60, -38, -4, -13, 42, -5, 13, 33, 13, -22, 23, 33, -9, -1, -14, 13, -22, -28, -16, 42, 32, 22, 17, 30, -23, -51, 32, 47, 14, 66, -23, 26, -5, -52, -7, 81, 34, -5, 23, 60, -5, -49, -11, 46, -19, 97, -16, 21, 63, 53, -10, 102, 16, -26, -16, 60, -13, -47, -46, 43, -2, 100, -10, 31, 74, -1, 1, 74, -5, -19, -11, 75, -23, -23, -1, -2, -1, 80, -14, 37, 51, -21, -1, 45, 1, -5, -1, 71, -9, 34, -2, -16, -11, 36, -21, 1, -30, 10, -1, -26, -2, -7, 17, -30, 5, 36, -2, -92, 1, -56, -1, 31, -14, 31, 2, -37, -30, 5, 18, -25, -16, 38, -25, -42, -9, -46, 5, 32, -23, 25, 5, -115, -9, -16, 1, 13, -25, -5, -59, -30, -18, -60, -2, 18, -22, 5, -2, -93, -16, 19, 1, 13, -14, -9, -72, 45, -4, 60, -13, 13, 1, -14, -1, 13, -38, 23, -18, 32, -25, -45, -66, 7, -16, 112, 1, 23, 39, -23, 5, 53, -1, 31, 4, 42, -11, -28, -47, 23, -18, 127, -2, 9, 66, -1, -13, 56, 5, -1, -16, 23, -7, -34, 63, 2, -7, 125, -9, 11, 81, 2, 1, 72, 5, -31, -14, -43, 2, -49, 103, -10, -2, 60, -2, 25, -30, 33, -34, -5, -5, 5, 2, -32, -2, 21, 23, -49, -13, -112, 10, 14, -80, 38, 7, -55, 7, -2, 13, -52, -34, 52, -61, -14, -2, -45, -31, 28, -56, 2, -21, -101, 1, -2, 17, 71, -1, 43, -28, -21, -7, -37, -22, 10, -92, 67, -19, -115, -9, 19, 2, 22, -1, 1, -71, 31, -18, -65, -11, 30, -118, 116, 13, -51, -28, 19, -2, 13, -31, 14, -93, 36, -19, 53, -11, 21, -67, 76, 26, 73, -37, 52, -1, -25, -17, -26, -94, 43, -19, 115, 5, 17, -21, 36, -2, 94, -30, 42, -2, -56, -7, -53, -84, 17, -13, 127, 11, 10, -5, 34, 2, 65, 1, 18, -13, -41, -11, -114, 13, -5, -4, 55, -2, -42, 13, -1, -2, -5, 7, -30, -41, 10, 2, 19, 4, -53, 4, -79, 2, -4, -26, 63, -23, -5, -19, -23, -23, -2, -4, 41, -5, -88, -2, -76, -5, 5, -23, 51, -32, -94, 23, -17, -21, -33, -2, 43, -47, -23, -13, -41, -9, 23, -55, 32, -7, -128, -38, -11, 2, 43, -21, 53, -61, 18, 5, -88, -13, -5, -109, 9, -4, -128, -36, 32, -11, 7, -2, 57, -74, 41, -23, 37, -36, 22, -80, -32, -9, -60, -32, 22, 7, 49, -7, 25, -83, 76, 10, 127, 5, 18, -37, 32, -21, 18, -57, 51, -17, 10, -1, -37, -104, 39, -19, 127, -1, 30, -23, -14, -2, 39, -45, 16, -21, 11, 23, -104, -39, -5, -21, 92, -22, -19, 55, -73, -13, 16, 16, -36, -19, 21, 14, -17, 42, -1, -25, -34, -5, -14, 57, 59, -7, -30, 25, -19, 14, 26, 1, 2, 21, -28, 1, -41, -16, 5, 42, 37, 10, -38, 1, -55, 1, 36, -5, 9, -2, -41, 13, -87, -13, 38, 23, -17, 1, -98, 13, -25, 21, -1, -2, 42, 1, -1, 5, -99, -1, 26, 1, 23, -21, -80, -31, -47, -10, 18, 18, 67, 33, 63, -2, -94, 2, 31, -2, 19, 2, -61, -21, -1, 11, 25, 23, 80, 36, 73, -1, 33, -28, 19, 2, 16, -2, -46, -23, 11, -2, 49, 18, 53, 25, 53, 5, 115, -13, 5, -5, -14, 16, 41, -18, 1, 2, 43, 13, -18, 46, 1, -4, 72, -11, 22, 33, -30, -19, -4, 1, -34, -36, 5, 7, -43, 51, -36, 16, -2, -2, -26, 72, 13, 2, -19, 31, -32, 16, 33, -1, -37, 52, -67, -16, -23, -31, -1, 33, 104, 4, 25, 52, -32, 10, -2, -34, -51, 56, -53, 13, -103, -13, 17, 67, 11, -17, 63, 36, -33, 13, -33, -11, -4, 36, -42, -4, -119, -17, 32, 51, 11, -9, 72, 53, -13, -11, -10, -5, 36, 51, -1, -11, -128, -22, 14, 34, 10, -36, 84, 57, -36, 2, 1, -5, 57, 110, 57, -16, -128, 7, 28, 56, -22, -31, 75, 43, -32, 5, 33, 5, 77, 45, 59, -11, -57, -4, 34, 53, 21, -9, 80, 5, -25, -19, -22, 7, 75, -5, 26, -1, 14, -9, -2, 36, 32, 5, 17, -7, -13, 37, 31, 11, -2, 9, -4, -4, -16, -23, -13, 16, 43, -9, -2, 21, 10, 2, 30, -5, -19, 25, -56, 1, -51, 7, 16, -38, 19, -18, 30, 32, 13, -2, 25, -9, -55, 37, -91, -11, -125, -1, 41, -5, -22, 1, 75, 56, 26, 2, 14, -1, -2, 72, -80, -13, -90, -13, 16, 13, 22, 2, 127, 56, 4, -9, 45, -10, -23, 52, -21, -5, -114, -9, 31, 4, 16, 2, 127, 63, -7, 7, 61, -25, -49, 98, 34, -5, -59, -19, 11, -23, 18, -2, 127, 67, -37, -16, 102, -16, 42, 46, 46, -4, -74, -23, 7, -38, 25, 4, 102, 16, -23, -9, 79, -23, 93, 43, 30, -1, -39, 2, -10, -42, 90, -7, 18, -11, 9, 11, 16, -11, 42, -21, 7, -13, 28, -4, 38, -31, 59, 10, 13, -11, 2, 7, -1, 1, 2, 23, -49, -14, -16, -16, -21, -60, 45, -2, 7, -10, 33, -13, -13, -23, 1, 53, -34, -5, -32, -1, -10, -76, 13, -19, -28, 9, 16, -13, -71, -9, -4, 23, -47, -2, -5, -11, -22, -47, -33, -1, 115, -2, 19, -7, -72, -38, 1, 75, -57, -5, -30, -34, 31, -46, 2, 7, 126, 5, 34, -4, -94, -25, -72, 119, -28, 2, -28, 2, 23, -34, 31, 16, 127, 59, -23, 16, -128, -9, -98, 99, -18, -2, 1, -18, 10, -41, 10, 4, 127, 52, -67, 2, -126, -28, 30, 4, -26, 18, -34, 7, -11, 2, 11, 18, 25, 16, -2, -22, 38, -5, -11, 13, 51, 16, 37, -22, 21, -7, 41, -16, -33, -16, -13, 1, 19, -16, 56, -23, 14, 5, 51, -7, -23, -7, 39, -2, -49, -9, -26, -13, 32, -2, 28, -46, 16, -10, 26, -13, 25, -1, -5, -5, -2, -19, 1, -1, 31, 1, 28, -49, -28, -1, 11, -1, -33, -32, -79, -7, 81, -43, 46, 13, -28, -18, 60, -77, -13, -5, -14, -16, -5, -39, -1, -7, 91, -34, 52, 2, -19, -33, 22, -2, -19, -2, -23, -10, 28, -38, 34, -14, 112, -7, -7, -21, -128, 23, -97, 43, -17, -16, -2, -1, 18, 75, 18, -28, 124, 16, -88, 23, -128, 9, -81, 76, -31, -23, 13, -9, -5, 14, -9, -10, 17, 9, -7, 16, 45, -10, -7, 31, 43, 1, 22, -10, 11, 16, 59, 4, 36, -2, -5, -4, 52, 2, 13, -26, 10, -9, -2, -18, 17, 21, 60, -30, 18, 11, -23, 5, 30, 2, 49, -30, 34, -21, -41, -7, 33, 11, -5, -32, 25, -2, -42, 19, 43, 4, 37, 4, 5, -2, -1, 2, 16, -25, -17, -19, 38, -1, -42, -5, 13, 18, 81, -49, 39, 16, 38, -16, 19, -52, 2, -38, 49, -32, -11, -17, -49, -21, 88, -88, 103, -14, 127, -33, 19, -51, 19, -23, 34, -67, -22, -1, -128, 5, -25, -49, 43, -5, 91, 5, 26, 16, 23, -7, 43, -63, -97, -38, -128, -5, -59, -42, -36, -2, 127, -13, 9, 17, 39, 33, 41, 25, -1, 5, -5, 1, 21, 63, 7, 10, 2, 1, 17, 22, 36, 19, 34, 5, -21, -18, -17, -2, -5, 32, 30, 2, -5, -5, 33, 21, -4, 19, 53, 30, -2, 13, 1, 11, 9, 28, 21, -2, -25, -22, -2, 11, -59, -11, 33, 23, -28, -4, -14, -9, 38, 11, 9, 2, -16, -2, 4, -38, -74, -36, 32, 10, -57, 4, 53, -11, 72, -31, 26, 11, -18, -10, 30, -118, -75, -97, 18, -17, -56, -26, 47, -28, 112, -67, 127, 1, 59, -36, 13, -128, 10, -41, 7, -52, -91, -25, 76, -16, 57, -128, 97, -14, 118, -22, 34, 42, 22, -63, 2, -83, -124, -51, 61, -13, -51, -121, -23, -2, 127, -25, -73, -51, -10, -74, 21, -60, 25, 38, -46, -89, -48, -37, -81, 51, -128, -69, 12, -64, -97, 55, 67, 46, -102, 81, -74, -77, -117, -70, 39, -39, -124, -31, -68, -67, -11, 42, -1, 29, -128, -80, -80, -113, -127, 2, 12, 45, -55, 73, 7, -21, -30, -23, -11, -10, -82, 10, 60, -80, -75, -53, -128, -30, -87, 31, -102, -61, 2, -28, 73, -3, -125, -29, -46, -27, -63, 29, -73, -60, -35, -36, -7, -35, -7, -48, -73, 10, -60, -59, 12, -91, -64, -18, -39, -24, -18, -48, -51, -55, -21, -63, -22, -21, -91, -55, 18, -70, -75, 39, -53, 4, 2, -60, -43, -85, -12, -75, -43, -60, -80, -63, -74, -16, -45, -31, -105, -41, -46, -59, 103, -24, -38, -58, -4, -28, -44, -80, -15, -70, -7, 10, -82, -23, 16, -64, 3, -6, -111, -48, -8, -30, -67, 29, -12, -23, -19, 2, 95, -25, 64, 3, 10, -37, -23, -6, 27, 4, -107, -31, -39, 16, -118, 51, -28, -102, -3, 19, -63, -25, 10, -45, -6, 94, -85, -12, 127, 127, -93, 5, -36, -38, 7, 60, -112, -45, -35, -23, -87, 25, -121, -1, 127, 22, 24, 12, -84, -10, -5, 29, -12, 22, 1, -51, -43, -92, -72, 1, 85, -128, -73, 1, 36, 1, -124, -28, -46, -128, -1, -36, -64, -5, -62, 58, -3, -42, -107, -30, -124, 98, -111, 1, -35, -63, 6, -5, -58, 28, -91, -10, -48, -24, -99, -39, -68, -89, -118, 3, 12, -118, 72, -89, -61, -51, -51, 44, -87, -90, -80, -51, 22, -4, -30, 41, 11, 53, 61, -29, 38, -5, -21, 34, -61, -91, 44, -23, -6, -49, 44, 22, 62, 51, 36, -46, 3, 8, -58, -1, -77, 8, -128, 98, -16, -51, 123, 80, 49, 53, -2, -45, -21, -36, -69, 34, -42, 1, -5, 67, -53, -48, -73, 4, -43, 49, 53, -58, -5, -74, -128, 60, -16, -30, -92, 72, -21, -48, -48, 86, -28, -22, -86, -64, -22, -39, -128, -4, 12, -128, 68, 29, -124, -3, -39, 60, -88, -53, 51, -84, -63, -25, -74, 35, 23, 2, -59, -62, -58, 12, -45, -30, -22, -59, -90, -107, 1, -85, -25, -30, 15, -23, -116, 25, -97, -24, -55, -43, -62, -128, -19, -22, 24, 55, -24, -31, 22, -111, -94, -128, 28, -51, 43, 53, 44, -43, 70, -61, 22, 27, -21, -51, -30, -51, -59, 63, -5, -22, -48, 1, 59, 77, 34, -64, 6, 46, -87, -58, 59, -37, -62, 18, 73, -42, -22, 10, 15, 4, 42, -70, 28, 1, -109, -1, -23, 37, -61, 1, 39, -27, -68, -12, -7, -19, 67, -36, -6, -84, -125, 58, -37, 62, 36, 95, -46, -44, -75, -1, -34, 49, -30, -10, -93, 15, -107, 8, -12, -28, -74, 58, -1, -25, -46, -2, -42, 29, -29, -61, -128, -28, -128, -7, -1, -128, -8, -18, -118, -74, -29, -63, -77, -30, -21, -37, -34, -6, -94, 8, -25, -19, 11, 10, -62, -62, -74, -2, 51, -37, -1, -27, -16, 29, -60, -81, -70, -118, -28, -15, 5, -61, -45, -11, -51, -84, -10, -28, -10, -36, -31, 98, 2, -38, -112, -5, -55, -85, -11, -55, 80, 39, 108, -72, 12, -34, -74, 49, 111, -64, -49, -34, -34, -19, -34, -10, 74, 127, 86, -29, -23, -81, -28, 12, 94, -42, -16, -6, 18, -53, -73, 46, 24, 35, 12, -75, -6, -51, -84, -37, 62, -23, -64, -30, -29, -42, -51, -53, 8, 63, 103, -59, 41, -30, -97, -19, -51, -23, -7, -29, -24, -58, -38, -82, -21, 51, -64, -55, -59, -87, -128, -18, -51, 31, -6, -30, -128, -70, -94, -18, -61, -84, -90, -29, -103, -42, -58, 7, -11, -11, 58, 24, -90, -5, -22, 48, 72, -45, -93, -72, 97, 19, -39, -34, -16, -111, -75, 6, 41, -6, -112, -92, -34, -15, -25, -42, 124, -39, -30, -35, -80, -69, -43, -106, 23, -67, 68, -70, -7, -10, 16, -24, -77, 12, -27, 42, -70, -37, 29, -92, -67, -48, 31, 18, -59, -2, 51, -77, -30, -72, -60, -10, 7, -23, -46, 60, -109, -51, 84, 30, -82, -72, 55, -53, 2, -62, -73, 2, -55, -73, -29, -18, -44, -10, -59, 19, -51, 18, 37, -24, -35, -58, -107, 30, 3, -30, -80, -35, 3, -49, -77, -21, -86, -22, -48, -51, -44, 1, -128, 10, 4, 27, -114, -12, -121, -30, -128, 61, -92, -51, -70, -15, -23, -12, -77, -21, -12, 34, -46, -28, -111, -88, -37, 41, -42, -48, 42, -10, -12, 24, 15, -82, -18, -64, -84, -128, 58, -44, -28, -30, -72, -75, -62, -60, 34, -8, -45, -12, -61, -15, -23, -51, 44, -58, 77, -41, -19, 48, 80, -37, 125, 12, -23, 7, -128, -15, -12, -11, -29, -80, -105, -38, -46, -85, 85, -82, 15, 1, -63, -59, -99, -63, 15, -62, -63, -58, -118, -18, -53, -112, 38, -35, -23, 15, -88, -10, -6, -91, 24, 84, -128, 6, -28, -21, -36, -2, 97, -42, 53, 1, -73, -38, 7, -11, -31, 55, -128, -61, -25, -31, -77, 22, 41, 7, -107, -22, -42, 10, -48, -59, 6, 10, -90, -31, 1, -46, -43, -34, -11, -34, -5, -93, -77, -10, -51, 77, -59, 12, -128, -51, -39, 45, 15, -23, 2, 19, -16, -2, -95, -60, 64, -10, -37, 44, -1, -75, -95, -91, -16, -74, 127, -111, -49, 19, -81, -41, 43, 51, -30, -12, -11, -63, -30, -98, -28, -46, 74, -59, -53, -44, -43, -3, 18, -70, -81, -43, -4, -46, -58, -3, -31, -46, 6, -15, 5, 37, -15, 16, -36, -62, -31, -34, -59, -72, -62, 24, -58, -86, 27, -35, -35, 25, -37, -2, 49, -107, -124, -109, 89, -60, 1, 2, -75, 51, 63, -61, 103, -97, -21, 12, -19, -8, -36, -7, -128, -67, -38, -16, -51, -45, 22, -43, -10, -125, -87, 48, -27, -35, -120, 97, -108, -63, -42, 4, -48, -7, -36, -25, 5, 10, -91, 4, -12, -31, -64, 35, -73, -51, -62, 6, 41, -58, 22, -6, -44, -3, -128, -91, 1, -58, -61, -125, -81, -68, -63, 70, -44, -89, -98, -81, -21, -44, -88, -87, 34, 19, -82, -70, 114, -25, -15, 15, -67, -37, -3, 1, 4, -12, -128, 24, 36, -36, -70, -70, 12, -58, -25, -21, 3, -114, 3, -74, -128, 7, -49, 22, 69, -86, -45, -63, 7, -88, -105, 61, -28, -128, -25, 6, -59, -51, -93, 42, 70, -51, -34, -127, -103, -111, 8, 3, -29, 41, 92, -38, 59, -107, -63, 27, 2, -31, -128, -62, 44, -2, 48, 2, -55, 21, 99, -53, 82, -106, -61, -36, 102, -98, -91, 127, -128, 7, -81, 15, -37, -37, -58, 10, 45, -70, -72, -53, 3, -4, -128, 24, -128, -43, -45, -51, 23, -53, 72, -80, -112, -114, -90, -4, -44, -62, -102, -128, -25, -29, -118, -64, -15, -86, -23, -22, -87, -128, -86, -39, 48, -24, -70, 16, -58, -111, -90, -12, -46, -46, -95, -35, -43, -70, -128, 4, 42, -48, -39, -77, -43, -1, -62, -4, -3, -30, -128, -70, -18, 43, -98, -21, -128, -88, 1, -97, -44, -82, -45, -7, 1, -103, -44, -12, -1, -41, -73, -7, -16, -105, -45, -38, 46, -90, -112, 4, -51, -84, -39, -23, 45, -24, -12, -12, 5, -128, -28, -72, -124, -37, 94, -5, -106, -128, -42, -5, -8, -99, -31, -37, -69, -44, -118, -38, -107, -91, 51, 6, -37, -89, -1, 2, 84, -124, -99, -25, -36, -44, -118, 44, -128, -84, 15, 27, -31, -105, -53, -89, -92, -23, -28, 46, -51, -51, -88, -99, -25, -41, -41, 22, 61, -128, -102, -72, -7, -91, 12, -48, -94, -30, -117, -75, -58, -53, -53, 38, 63, -92, -16, -44, -6, -21, 29, 7, 16, -24, -74, -93, -36, -73, -11, 19, -67, 7, -11, -19, -55, -93, -28, 2, 30, -51, 12, -30, -98, -69, -58, 5, -35, -109, -64, -82, -27, -44, 67, -55, -39, -12, -45, -41, 12, -38, -25, -3, -25, -128, -63, -43, -24, -128, 7, -10, -68, -70, -10, -128, 81, -27, 82, 25, -31, -128, -38, -68, 118, -121, 87, 5, -34, -34, -80, -49, -46, -87, 24, -38, -64, -98, -80, -46, -107, -128, -103, -6, -123, 38, -128, -91, -63, -10, 127, 25, -4, -128, -64, -62, -103, -59, -44, 31, 12, -51, -93, -98, -48, -73, -93, 36, 39, -123, -80, -49, -93, -77, 12, 35, 1, -80, -128, -128, -55, -72, -74, 2, 22, -116, -48, -45, -102, -12, -60, -44, -10, -63, 28, -92, -84, -37, -99, 2, -45, -28, -51, -7, -59, 2, -36, -43, 35, 72, -94, -55, -80, -30, -106, 2, -69, -128, -44, -39, -70, -87, -73, -6, 73, -77, 48, -73, 114, -58, -86, 59, -35, -49, 4, -72, -77, -95, -108, -1, 36, -128, 39, -92, 68, -21, 82, -10, -15, -128, -11, -61, -105, -81, -93, -4, 3, -24, 30, -29, 43, -58, 98, 43, -34, -70, -82, -44, -63, -128, -6, -1, 25, -35, -102, -128, -81, -53, 93, -50, -81, 64, -35, 23, -36, -48, -69, -91, -20, -95, -120, -40, -14, -96, -95, 8, -126, 23, -17, -81, -69, 3, -111, 97, 36, -81, -83, -47, -5, 57, 81, -80, -73, -8, -88, -120, -81, 86, -111, 48, 40, -108, -43, -61, -72, -24, 8, -68, -20, 49, 28, -125, -24, 1, -20, 47, -48, -102, -119, -12, -127, -18, -7, 23, -62, 17, -14, -49, -5, 9, -19, 20, 13, -128, 20, 20, -128, -65, -8, 41, -8, -30, -14, -53, 34, -61, -119, -13, -2, -12, -60, 36, -47, 26, -26, -11, -92, -91, 18, -70, -83, 56, -52, -6, -14, -49, 25, 47, -44, -28, 1, -109, 95, -101, 36, -30, -66, 7, -114, 34, 127, -53, -55, -33, -106, -45, -88, -113, -53, 39, -31, -103, 7, -49, -123, -5, -125, 39, 53, -35, -76, -95, -118, -3, -76, 8, 52, -121, -70, -20, -77, 103, -72, 77, 48, 36, -24, -128, -17, 48, -28, -44, 20, -30, 15, 59, -50, 52, 97, -41, -41, -41, -17, -46, -1, 71, -88, -14, -17, -83, 1, 2, -108, 7, 14, -106, -110, 25, 17, -12, -82, 66, -98, 23, -50, -115, 4, -11, -59, 18, 41, -126, -103, -35, -11, -50, -62, 29, -6, 1, 3, -7, 68, -3, -83, -38, 29, -9, -4, -15, -59, -26, 20, -23, -8, -40, -18, -44, -57, 4, -36, 71, -43, -19, 35, 19, -52, -91, 40, 88, -90, -95, 82, -70, -26, -50, -92, 64, 31, -53, 29, 41, -119, 66, -50, 26, 2, 17, 9, -7, 41, -25, 47, -71, -95, -91, -34, 14, 29, -62, -57, -128, 53, 36, -88, -28, -53, -93, 34, -7, -36, -6, 60, 35, 26, -87, -6, -2, -46, -34, -70, -114, -71, -73, 59, -14, -86, -4, 39, 43, 12, -72, 18, -33, -88, -20, -3, -128, -20, -60, 55, -33, -35, -19, -64, 5, 46, -33, -60, 3, -77, -20, -59, -88, -9, -10, -3, 87, -20, 76, -52, 14, -53, -56, -2, -61, -60, -85, -128, -115, 47, -20, -109, 34, 10, -10, -90, 45, -118, 1, -13, -1, -35, -90, -128, -120, 4, 123, -111, 49, 36, -60, 81, 6, -56, -122, 70, 56, -68, -12, 69, -36, -33, 109, -72, 2, 5, -62, -12, 43, -90, -10, 71, 1, 15, 28, -88, -15, -20, -24, -128, -43, -100, -47, -77, -47, 14, -77, -40, 57, 52, -8, -100, -128, 35, -128, -97, -5, -61, -99, -83, -3, 9, -26, -70, 3, 25, 19, -118, -26, -31, -46, -83, 29, 39, -57, 99, 41, -3, -28, -1, -9, -110, 39, -95, -65, 38, -81, -9, 68, -76, 29, -102, 35, 66, -53, -2, -6, -118, -7, -117, -93, -93, -69, -72, -2, 11, -56, -128, -25, -76, -50, 26, 38, -73, 26, -128, -39, 34, -43, -35, -38, 12, 1, 35, -79, -128, -100, 13, -55, -36, 48, -93, -25, -41, -128, -71, -45, -17, -17, 61, 10, -119, -17, 10, -71, -47, -35, -64, 19, 14, -88, -121, 70, -56, 45, 7, -92, -20, -30, 40, 10, -15, -26, -44, 85, 7, -128, -109, -62, -92, 33, -15, -33, -18, -105, 30, 34, 64, 66, -76, -38, -35, -33, -123, -6, -93, -61, -91, -26, 86, -91, -52, 7, 19, 36, -110, -59, -38, -97, -61, -43, -61, -31, -3, -69, -45, -48, 10, -7, -73, 19, -59, -47, -19, -126, -83, -17, 39, -26, -103, 87, 19, -128, 26, 62, -48, 26, -47, -66, 2, -8, -80, 20, -90, 36, -92, 30, -39, 20, 14, -44, -100, 23, -73, -99, -44, -17, -35, -17, -9, 26, -90, -57, 12, -20, -55, -24, -66, 34, -38, -99, -29, -88, -61, -91, 23, -12, 66, -4, -79, -91, -6, -6, -77, -26, -85, -44, -30, -92, -24, -40, 8, 36, -62, -13, -128, -128, 3, -10, -50, 41, -77, -20, -10, -19, -61, 18, 73, 61, -29, -4, 83, -76, 45, -125, -56, -5, -70, -45, -3, 127, -93, 5, 33, -46, -115, -49, 28, 12, 18, -33, 127, -3, 31, -100, 43, 117, 12, 41, -50, -105, -13, -49, 24, 9, -20, -12, 127, 17, -29, -122, 93, -25, -69, -76, -9, -82, -61, 31, -44, -128, 35, 6, -68, -11, 87, -101, -7, -112, -60, 69, -29, 31, -87, -25, -49, -108, -7, 20, -76, -33, 5, -128, -19, -98, -85, 50, -64, 106, -126, 19, 6, -62, 76, 45, -110, 77, 77, -66, -33, 52, -115, 38, -24, 31, 3, 69, -69, -43, -60, -48, -128, -88, -36, -39, -24, -23, -95, -12, -45, 2, 28, 9, -108, -57, 19, 17, 36, 11, 71, 12, -70, -95, -120, 36, 72, 90, -88, 25, -1, -128, -55, -125, -91, -36, 36, -83, -18, 127, -86, 45, 12, 43, 28, -24, -80, -64, 62, -12, -66, -31, 7, -57, -6, 109, -34, -4, -57, -87, -99, -95, -9, -6, -28, 56, 24, -69, -41, -29, -26, -44, -105, -17, -18, -82, -34, -1, -20, -23, -45, 4, 10, -4, -29, -5, -10, -128, -65, -64, -6, 55, -44, -20, 55, -43, -53, 81, -123, 25, -85, -43, -11, -49, -36, -33, 73, -3, -111, 73, -24, -114, -4, 50, -49, -128, 52, -128, 56, 96, -105, 13, -6, -128, 31, 23, -62, -85, -24, -29, -100, -128, 59, -101, -4, -68, -71, -28, 8, -23, 10, -19, -117, -125, 1, 36, 31, 26, -13, -128, 1, -53, -10, 97, -6, 95, -126, 5, -44, -128, 9, -128, -126, 5, -26, -73, -28, 83, -123, -41, 52, -18, -88, -26, -68, -41, -20, -19, 64, -25, 62, -83, 28, 116, -102, -52, 60, -65, 96, -52, 17, -8, -43, 10, -11, -1, -2, -56, -36, -31, -123, -1, 50, -83, -81, 53, -15, -102, -10, -50, -110, 2, -55, -2, -30, -128, -128, -2, 59, 122, -55, 17, 55, -99, 36, -19, -82, 4, -95, -66, -93, -128, 3, 90, -36, -44, -76, -44, 59, -83, 31, -31, -66, -6, 1, -41, 1, 127, -128, -25, 72, -34, 92, 34, -28, -70, -15, -73, -83, -43, -47, -92, 2, -55, -128, 2, 34, -31, -55, -36, -33, -91, -34, 65, -30, -11, -79, -72, 8, -60, -79, -80, -82, 86, -128, 33, -17, -52, 9, 52, -110, 47, 120, -26, -30, 126, -117, 76, -92, -82, -6, -44, -39, -71, 28, -56, 112, 46, -56, -50, -41, -15, -93, -34, -81, -62, -23, -5, -45, -46, 49, 1, 3, -19, 122, -39, 31, -103, -52, 36, 13, -30, 6, -76, 38, -100, 50, 18, 24, -10, 47, -83, -9, -2, -126, -71, -1, 127, -120, 23, -80, -23, 76, -56, 57, 49, -117, -125, -11, -55, -57, -1, 18, 127, -56, -19, -9, -121, 14, -73, -90, 3, 127, 1, 17, -122, 28, -25, 26, -119, 20, -2, -64, -106, -33, -4, 95, -128, -91, -26, -26, 127, -83, 88, 10, 15, 73, 8, -103, -34, -73, -60, -30, -71, -1, -97, 43, -73, -102, 18, -34, 73, -128, 28, -44, -128, -3, -17, -97, -17, -6, 3, 1, -47, -23, -40, -19, -25, -31, -13, -12, -81, -46, 39, 95, 79, -9, -20, 49, 68, -53, -44, -31, -47, -68, 39, -66, -55, -8, 83, 17, 18, -45, -36, -82, -112, 96, -59, -64, -128, -44, 34, 9, -47, -64, -86, -28, 4, 40, -29, -61, -115, 24, -64, 43, -128, -64, -17, 80, -92, 76, 40, 56, 33, -62, -47, 20, -10, 28, -25, -35, 127, -55, -56, -44, -64, 31, -38, -73, -79, -66, -127, 18, -86, -85, 52, -41, -101, -95, -11, -50, -100, -6, -12, -105, -106, 4, -66, 29, -52, -119, -28, -10, 48, -30, 26, -43, -31, -83, -38, 13, -2, 31, -34, -80, -128, -18, -20, -46, 114, 20, -70, -20, -48, -40, -24, -46, -47, -79, -31, 26, -128, -60, 7, -90, -57, 87, -46, -5, -53, -69, -72, 82, 24, 2, -66, 45, 62, -6, -23, -98, -128, -118, -44, -2, -119, -93, 52, 24, 20, -45, -56, 62, 20, -71, -1, -36, -128, -30, -82, 35, -128, 62, 2, 18, -34, -18, -114, 80, -128, 31, -2, 88, -82, -15, 33, 45, 20, 86, 23, -10, -20, -128, -19, -11, -102, -25, 13, -128, 127, -97, 26, -41, -88, 86, 24, -102, -57, -80, -39, 24, -46, -53, 20, -30, -70, -73, 46, -68, -123, -45, 3, -62, -99, -110, -35, -13, -128, -82, -11, -55, -30, -13, -4, -87, -101, -40, -9, -18, -17, 6, -12, -23, -113, -9, 28, -2, 80, -95, -18, -6, -65, 43, 50, 62, 25, -111, -53, 34, -20, -12, -20, -103, 82, -121, 18, -3, -128, 44, 2, -106, -105, -62, -100, 25, -92, 46, 46, -81, -5, -7, -36, 35, -65, -1, 2, 120, -41, -48, -12, 3, -66, -83, -14, -98, 10, -103, 36, -35, -128, -2, 62, 15, 10, -110, -115, -30, -5, -9, -33, -23, -71, -100, -11, -2, -128, -29, 66, -65, -36, -73, -3, -28, -79, 8, 68, 61, 43, -24, -14, 24, -57, -91, -2, -38, 70, -38, -128, -1, -44, -62, -50, 31, 8, -14, 83, 19, -76, -23, -15, -59, -4, -82, -20, 1, -50, 28, -56, -5, -56, -110, -64, -108, -92, -29, 20, 31, -116, -10, 16, -32, -101, 28, 43, -113, -46, 81, 5, -99, -35, -81, 29, 18, -114, -1, 20, -61, -128, -8, 15, -93, -101, -31, 10, 16, -5, -49, -24, -10, -80, 31, 15, -81, -128, -78, -15, -67, 29, -92, -7, 31, -20, -24, -20, -7, -48, 28, 10, -31, -128, -14, -46, 4, -7, -128, -5, 68, 3, 26, -29, 4, 2, 5, 18, 10, -108, 19, -8, -10, -5, -78, 12, 46, -3, 46, 5, -34, 48, -69, -16, 29, 64, -28, -29, 7, -1, -46, -2, 20, 31, 78, 10, -14, 86, -69, -34, 15, -29, -49, -24, 63, 49, -24, -15, -4, -1, 36, -1, -43, 87, -12, -10, -14, 19, -67, 20, -8, 40, -3, 18, -34, 5, 8, -24, -28, -120, 16, -3, -24, -120, -26, 19, -99, -49, 101, -128, -68, 4, -124, -10, -4, -128, -69, -1, -43, -128, 51, 5, -122, 3, 23, -111, -46, -26, -89, -1, 5, -86, -93, 23, -24, -128, 18, -23, -101, 1, -34, -95, -12, -10, -26, -14, -3, -36, -80, 10, 3, -93, 35, -10, -16, -49, -128, -79, 38, -7, -7, -7, -23, -5, -128, 19, 29, -3, 65, -35, 19, -35, -83, 46, 79, -14, 24, -12, -18, 83, -128, -14, 79, 78, 7, 2, 14, 8, -34, 46, 68, -2, 85, -24, -3, 114, -4, -10, 46, 64, -85, 4, 86, 49, -39, 3, 3, -23, 43, -28, -24, 80, 16, -23, 39, -122, -93, 7, 12, 1, 14, 1, -32, -14, 4, -24, 2, -128, -128, -127, -87, -59, -78, -5, -69, 20, 99, -102, -51, 28, -67, 20, 8, -122, -112, -113, -70, -97, 38, -1, -15, -48, 32, -128, -49, -16, -66, -24, 24, -97, -80, -97, -40, -112, 20, 15, -49, 49, -66, -124, 34, -29, -86, -12, 28, -64, -35, -38, -18, -51, 91, 3, -34, 7, -112, -89, 36, -1, 1, 32, 28, -63, -20, -10, 51, 1, 70, -8, 4, 20, -116, -64, 24, -19, -19, -12, -16, 43, 3, -74, 59, 19, 41, -15, 59, -36, -73, -67, 46, -26, 24, -15, -12, 81, 26, -10, 67, 63, -49, 3, 39, 10, -64, -24, 10, -4, 34, 12, -24, 49, -32, -3, 43, 114, -68, 32, -18, -91, 3, -95, -40, -5, 19, 26, 24, -4, -128, -35, -51, 24, -99, -23, -20, 48, 127, -2, -64, 20, -128, -4, 20, -119, -128, -29, -35, -66, -23, -18, -16, 10, 108, -111, -43, 3, -128, -10, 24, -84, -128, -49, -67, -105, -49, -26, -7, 26, 48, -113, 55, -10, -101, -1, 10, -128, -128, -64, -40, -124, 28, -8, 19, 24, -8, -128, 43, -16, -14, 1, 16, -128, 7, -86, 43, -48, 20, -1, 66, -8, -92, -89, 87, -24, 62, 2, -28, -80, -24, -14, 46, -48, 68, -18, 26, -51, -110, -99, 84, -4, 99, -5, -26, 7, -24, -26, 38, -40, 51, 2, -19, 51, -86, -84, 29, -28, 91, 1, 3, -4, -14, -12, 3, -19, -24, -7, -48, -18, -31, -61, -4, -16, 80, -35, 10, 20, -128, 89, -49, 70, 10, 23, -2, 92, -8, 51, -81, 19, -127, 32, -23, -3, -125, 20, -31, 14, -81, -24, -32, 92, 78, 16, -92, -24, -128, -8, 20, -8, -108, -1, -40, 79, -83, -7, -46, -5, 64, -7, 3, -24, -128, -10, 10, -85, -78, -29, -110, 3, -59, 10, -79, 24, 18, -2, 99, -4, -49, -4, 2, -105, 23, 8, -8, -69, 8, -1, -64, 10, 23, -83, 109, -15, 62, -4, 34, -18, 112, -24, -1, -91, 41, 7, -79, 10, 40, -73, 127, -34, 93, -8, -35, -61, -24, -1, -1, -101, 59, -10, 26, -14, -55, -87, 68, -7, 109, -15, -36, -35, -5, 2, -5, -113, -16, 7, 26, -1, -16, -5, -40, -12, 48, -24, 4, 46, 1, -43, 10, 93, 35, 34, -10, 93, -38, 36, -61, 1, -61, -12, 2, 18, 38, 39, 20, 93, 26, -10, 24, 59, -63, 69, -69, -36, -125, -10, 23, 8, -15, 28, 1, 97, -38, 2, -68, 24, 1, 19, 20, 32, -69, -24, 28, -4, -128, 23, -24, 2, -19, -14, -64, -24, 12, 12, 102, -14, -66, 5, 15, -73, 4, -3, -7, -51, -19, 15, -35, -26, 14, -23, 97, -10, 32, 1, 24, -15, 28, -7, 1, -48, -18, -1, -4, 4, 29, -65, 112, -32, 66, -12, -24, 10, -1, -24, -29, -73, -23, 2, 43, 32, 24, -26, 67, -16, 119, 8, -16, -24, 1, -40, -3, -46, -1, 1, 18, 34, -7, 62, -14, -12, 61, -7, -4, 18, 46, -36, 16, 83, 26, -28, 14, 43, -59, 49, -49, 1, -20, -7, 19, 4, 7, -10, 10, 99, -3, -32, 14, 73, -63, 64, -32, 10, -65, -24, 24, 2, -43, -4, 5, 40, 10, -20, -1, 3, -70, 40, -35, 43, -81, 14, 24, 26, -14, 31, -2, 51, 12, -1, 16, -38, 1, 16, 46, -19, -49, 4, 12, 5, 14, 10, 15, 10, -29, -5, 18, -43, 24, -8, 38, -29, -12, 19, 39, -12, -10, -14, -29, -49, 41, -24, 43, -15, 36, -34, 63, -15, 43, -10, -2, 84, -20, -34, -34, -48, -28, 1, 120, -23, 39, 105, 49, -12, 43, 5, -32, 73, -5, -3, 12, 78, 3, -2, 38, -24, 73, 116, -3, -14, 59, 2, 18, 8, 39, -43, -18, 87, 51, -16, -4, 12, -16, 43, -31, 5, -15, 15, 20, -4, -24, -18, -16, 32, 24, 2, -10, 19, -5, 62, -5, 3, 16, -2, 31, -40, -46, 12, -24, 66, 12, -10, -32, 4, -23, 64, -7, -36, 1, 15, 4, -16, -73, -40, 4, 8, 16, 1, 55, 41, 10, 24, -10, 1, -32, -8, 1, -67, -29, 16, 2, 7, 10, -7, 95, 12, -3, -1, 51, -32, 16, -10, 10, -29, 36, 1, -7, -38, 4, -14, 99, -10, 28, -84, 14, -36, 43, 10, -19, 110, 35, -24, -43, -59, 1, -5, 15, -20, 68, -4, 26, -18, -5, 1, -5, 14, -20, -29, -38, 127, 12, -14, 97, -28, -65, 78, -1, -31, 55, 23, -10, 10, 31, -112, -41, 14, 24, -18, -20, -7, 29, -14, -1, 10, -49, -19, 12, -51, 48, -68, -66, 31, 32, -20, -3, 14, -10, -15, -35, -31, -41, -1, 24, -32, 34, -84, -80, -16, 23, 10, -4, -4, 3, -15, -14, 29, -35, 8, 10, -39, 7, -39, -85, 1, 18, 14, 8, -7, 65, 5, -16, 1, -16, 18, 16, -12, -5, -114, -40, -24, 19, 14, 31, 3, 20, -24, 32, -40, -1, 8, 24, -10, -28, -105, -23, -68, 49, -4, 93, -35, 51, -34, 1, -5, 24, 10, -28, 20, -8, -46, -10, -97, 55, 15, 80, -7, 48, -111, -10, -15, -20, 12, -23, 61, -29, -7, -43, -124, 38, 4, -67, -20, -8, 3, 10, -20, -4, -7, -12, -4, 48, 16, 20, 18, -41, -3, 12, 61, 20, -46, 26, 43, -15, -35, 1, -8, 64, 28, -38, 26, -55, 23, -24, 51, 26, 34, 41, 16, 32, -1, 10, 15, 59, 19, -12, 8, 23, 8, -34, -23, 2, -4, 64, 35, 23, 12, 34, 15, 10, 23, -20, -28, 59, -2, -43, -28, -20, 19, 26, 31, 20, -3, 24, 20, -69, -26, -40, -59, 3, 15, -7, -4, 19, 19, -3, -38, 64, -4, 23, -1, -32, 4, -38, 12, 14, 12, 14, 10, 39, 35, -1, -20, 35, 8, -3, -19, -35, -24, -16, -24, 49, 19, 79, -4, 46, -19, -4, -34, 46, 1, -7, -40, -18, 3, -16, -74, 68, -10, -84, 8, 15, -85, 31, -26, -10, -1, -15, 24, 38, 3, -16, 32, -4, 8, 99, 12, -7, 19, -15, 5, 35, -1, 1, 10, 18, 23, -7, 46, -3, -18, 65, 5, -43, -3, -8, 24, 8, -7, 3, 15, 48, -14, -41, 36, 4, 14, 38, 10, 20, 8, 3, 20, -66, -1, 12, 62, 95, 3, -14, 12, 24, -24, 67, 5, 28, -16, 8, 7, -7, 14, 24, 35, 62, 85, -23, 8, -29, 4, 89, -1, 35, 36, 19, 43, 5, -10, 15, 68, -20, 74, 7, -20, -10, -1, 93, 43, 32, 127, 4, -23, 43, -2, 18, 66, -1, 78, -10, 15, 8, 10, 109, 43, 23, 87, 34, -24, 110, -10, -39, 61, -15, -3, 7, 23, 91, -7, 89, 12, 20, 73, 8, -7, -16, -12, -5, 41, -24, 24, 18, 34, 49, 4, 19, -8, 18, 51, 10, 26, -1, -16, -18, -3, 15, 24, -19, 24, 23, 1, 108, -10, -36, 7, -16, 16, -12, 24, -24, 8, 29, -14, -18, 36, 8, 16, 74, 28, -40, 24, 18, 28, -41, -8, 26, 18, 91, -34, 34, 39, 3, 3, 89, 26, 67, 3, 15, 10, 5, -4, -4, 69, 127, 15, 46, 8, 14, 24, 29, -20, 5, 5, 1, 40, 16, 7, 24, 83, 123, 79, 38, 5, 10, 31, 5, 38, 23, 73, 28, -2, -18, 1, 34, 127, 64, -2, 10, 24, 43, 34, -68, 89, 40, 123, 26, -31, -2, -16, -2, 20, -10, 1, 10, 61, 43, -20, -59, 69, 63, 112, -15, -10, -65, -25, -33, -35, -66, -122, -43, 62, -18, -86, -61, -24, -110, -48, -50, -46, -8, -14, -36, -7, 4, -76, -92, 13, -76, -16, 19, -96, -5, -57, -96, -42, -70, -110, -21, -9, -51, -52, -33, -44, -128, -72, -23, -84, 69, 45, -33, -69, -4, -77, -107, -28, -3, -122, -55, 75, -128, -88, -110, -89, -14, -27, -110, -116, -66, -105, -13, 75, -16, -97, -46, -24, -104, -36, 50, -75, -52, 9, -78, -106, 10, -75, -118, -6, -46, -21, 42, 1, -80, -117, 14, -75, -94, -58, -92, 66, 79, -52, -91, -125, 2, -99, -80, -5, -17, -106, -71, 11, -13, -26, -22, -83, 11, -103, -44, -65, 53, -80, -83, -13, -96, -1, -86, 6, 39, -51, 2, -62, 127, -121, -100, 55, 41, -27, -39, 77, -56, -38, -77, 108, -45, 78, -52, -12, -47, -16, -128, 7, -70, -128, -87, 5, -18, -31, -45, 91, -69, -11, -9, -128, 7, -42, 15, 31, 4, 16, -22, -8, 1, -106, -128, -43, 127, 46, -72, -94, 47, -89, -51, -14, -40, -15, -22, 2, -65, -80, -43, -35, 38, 66, -62, -33, 50, -85, -122, -17, 25, -109, 9, -42, -75, -50, -62, -32, -122, 66, -48, -33, 32, -56, -121, 85, -38, -94, -9, 11, -38, 18, 21, -115, -46, 57, -51, -83, 1, 1, -24, 35, 15, -3, -6, -43, -1, -36, -7, -128, -128, -84, -1, -82, -55, -52, -53, -96, -128, -112, 91, 9, -113, -33, -72, -13, -76, -29, -7, -29, 39, 99, -41, 3, -98, -24, 34, -90, -52, -62, -84, -79, -128, -26, -16, -128, -48, -109, -52, 1, -66, -65, 62, -87, -31, 3, 24, -27, -38, 22, 7, -128, 32, -72, -53, -22, -12, -98, -25, -72, -31, -15, -2, -29, 13, 11, 46, -90, 9, -70, -105, -65, -97, -26, 50, -78, -32, 1, -18, -89, -1, -36, -8, -77, 80, 4, 3, -77, -110, -86, 66, -116, -55, 1, -48, -117, -128, 22, 84, -33, -40, -8, -17, 39, -77, -72, 10, -96, -17, -51, 7, -48, -104, -6, -40, -11, 89, -23, -88, -83, 76, -32, 39, -100, -85, -40, -50, -98, -53, -50, -65, -50, -21, 38, -42, -34, -101, -26, 79, -45, -75, -1, 31, -128, -80, 23, -117, -43, 127, -113, 66, -51, -78, -128, 65, -86, -47, 65, 97, 117, -43, -77, 33, -128, -55, -113, -29, -8, -72, -23, -31, -12, -108, -80, -62, -116, -112, -40, -15, -69, -61, -97, -15, -56, -122, -83, -80, -35, -62, -90, -78, -128, -3, 18, -128, -14, -26, -7, -18, 17, -108, -33, -15, -122, -16, 31, -87, -76, -92, -51, -52, -11, 5, 47, -61, 58, -107, -100, 18, -7, 1, -41, 65, -31, -51, -3, -29, -118, 55, -16, -55, 80, -39, -26, 70, 11, -61, 12, 21, -98, -109, 14, 105, -128, -29, -33, -57, -78, 7, -120, 43, -105, -16, -69, 22, -13, -60, 21, -108, -101, 31, 71, -85, -25, -15, -121, 13, -89, -119, 47, -33, -105, 24, 51, 5, 2, -40, -21, 127, -19, 75, 19, -25, -35, -48, 120, 113, -69, -24, 105, 23, -60, -32, 82, 65, -11, -48, -25, 19, -128, -53, 127, -122, -2, -92, -24, -51, -96, 17, -47, -55, -77, -36, -58, -57, -1, -112, -43, -50, 125, -103, -15, -42, -128, 46, -10, -36, -19, -32, -31, 8, -128, -121, 3, -6, -93, -125, 2, -97, -62, 72, -45, -82, -88, -11, -128, 5, 5, -90, 41, -51, -108, -125, 61, -43, -117, 71, 39, -61, 34, -118, -25, -42, -76, -104, 34, 32, -100, -107, -12, -66, -27, -15, -91, -94, -128, -65, -100, -29, -44, -128, -1, 44, -91, 2, -48, -76, -87, 14, 9, -85, -29, -21, -60, 28, -118, -12, -42, -61, -113, 55, -48, -88, -90, -104, 97, 99, 46, -44, -21, -89, -106, -94, 80, 11, -72, -24, -44, -19, 11, 6, 127, 112, -43, 99, -28, -17, -107, -17, 79, -125, -109, -103, -6, -42, -128, 35, -2, -27, -29, -128, -125, -78, -15, -93, -39, -115, -51, -82, -43, -10, -90, 31, -15, -104, 89, -118, -93, -34, -108, -27, -22, -86, -91, -32, 11, 29, -22, -22, 43, -38, 80, -75, -128, 52, -82, -22, 7, 43, 17, -124, -29, -119, -77, 84, -29, -104, -92, -38, -104, -28, -3, -69, -12, -18, -62, -106, 29, -80, -58, 12, 18, -62, 5, 50, -113, -38, 12, -84, -89, -40, -116, 71, 61, -70, -128, 35, -34, -62, -88, 42, -79, 43, -112, -43, 2, -22, 22, 36, -36, -80, -45, 109, -24, 79, -15, -3, -75, 38, -25, -103, -82, -100, -50, -104, -17, -27, -48, 13, -76, -7, 83, -128, -128, 65, -127, -1, -43, 19, -76, -42, 41, 23, -89, 15, -71, -104, 60, -42, -71, 41, -7, -58, -3, -2, -128, -31, -38, -58, -40, -42, -24, -103, 16, -103, 5, 43, -13, -18, 34, -56, -2, -97, 12, -52, 6, 1, -29, -128, -65, -13, -70, 8, -101, -91, -26, -21, -42, -93, 21, 40, -89, 25, 86, -32, 85, -35, -128, -14, -77, 15, -45, 86, 24, -28, -32, 15, 14, 80, -10, -27, 24, 101, -78, 46, -32, -91, 14, -18, -28, -125, 14, -7, -65, -80, -32, -96, -62, -69, 7, 69, 97, -56, 33, -24, -31, 6, -14, -112, -128, 8, -60, -26, 6, -13, -105, -84, -25, -84, 127, -55, -92, 14, -93, 13, -80, 23, 104, 127, 52, -27, -94, 71, -83, -128, -28, -91, -83, -128, -8, 46, -11, -79, -44, 40, 5, -16, -51, 9, -124, -22, 23, -113, -51, -45, -11, 35, -51, 51, 14, 99, -83, -12, -48, -41, -121, -50, 12, -22, -128, -41, 12, 42, -72, 35, 52, 61, 5, -17, -1, -84, -44, -48, 78, 42, 21, -86, -11, 96, -84, 50, 8, -78, -12, -65, -19, 11, -66, -128, 14, -8, 19, -65, 33, 119, -43, -26, 11, -104, 53, 127, -90, -84, -47, -110, 13, 39, -80, -79, -13, -71, -128, 27, -35, -44, -31, -101, -28, 62, 121, -13, -6, 51, 45, -72, -9, -103, -115, -53, 24, -35, 48, 103, -96, -7, -18, 106, -72, -118, -48, -56, -19, -31, 17, -46, 33, 92, -10, -46, -1, 2, -125, -22, -89, -62, -10, -75, -6, 32, 3, -65, 2, 46, 65, 3, -89, -69, -15, 69, 69, -14, -56, -117, 29, 53, -31, 28, 2, 93, 19, -76, -128, -100, -35, 51, -62, -128, -52, -88, -2, 42, -18, 9, 50, 112, -29, -62, -116, 23, -77, 79, -5, -104, -118, -55, -36, 65, -96, -13, 60, 24, 69, -86, -16, 18, -88, 13, 52, 21, -88, -51, 23, 116, -70, 38, -19, -90, 1, 4, -48, -47, -19, 101, 66, -79, -32, -57, -80, -109, -125, -36, -12, 4, -65, -62, -46, -11, -120, -90, 62, 34, 14, -42, -40, -45, -18, -6, 89, -42, 27, 26, -128, -128, -10, -55, 36, -40, -94, -89, -76, -2, -128, -66, -108, 101, 34, 71, -103, 53, -62, -48, -2, -43, -87, -26, -2, 11, -99, -8, -13, 127, -38, 15, -66, 3, -128, 14, 34, -57, -127, -47, 27, 25, -44, -13, 22, 52, -7, -53, -128, -85, -128, 110, 45, -128, -89, 13, -29, -39, -122, -29, -18, 56, -5, -107, -115, 1, -39, 86, -4, 72, -104, -71, 9, 43, 13, 13, 11, 1, -83, -65, 13, 21, -44, 1, -35, -128, 100, -92, -79, 119, -58, -28, 9, -6, -83, -51, -2, 10, -39, 72, 10, 27, -85, -128, -51, 4, -48, 48, 43, -56, -55, -128, -128, 7, -76, -48, 77, 34, 58, -110, -26, -128, -100, -71, 25, 1, -38, 18, -89, -120, -125, -97, 86, -128, 44, -87, 70, -2, -72, 34, -85, -41, -96, -15, -110, 17, -31, -112, 8, -97, -65, -128, 26, -42, 2, -84, 38, -51, 3, -128, -53, -80, -94, -61, -25, -70, -128, -79, 66, 31, -65, -25, 26, 47, -69, -106, -119, 40, -50, -84, -55, -80, -124, -43, -93, -25, -61, 46, -69, 119, -100, -70, -128, -128, -2, -3, 15, -78, -26, -22, -38, 82, -128, 22, 26, 29, 127, -56, -128, 48, -14, 1, 77, -1, 33, 70, -17, 103, -33, -38, -46, -14, 96, -10, -97, -29, -16, 14, -3, 127, -4, -109, -70, 127, -16, 5, -2, -97, -128, -36, -12, 33, -60, 120, -13, 35, 58, -110, -96, -62, -83, -48, 8, 14, -45, -89, -26, -52, -51, -84, 18, -29, -33, -56, -46, -17, -52, -34, -60, -1, -116, -88, -56, 62, -43, -10, -44, -42, -83, -103, -9, 87, -61, 10, -5, -82, 31, -43, 17, -3, -113, 19, -57, 15, 117, -84, -34, 16, -15, -88, 26, 127, -97, -6, -70, 33, -128, 6, -17, -5, -99, -100, 35, 15, -8, 17, -86, 36, -29, -113, -92, -34, -27, -14, -24, -43, -83, -84, -19, 13, -32, 83, -26, 46, 29, -87, -87, 25, -58, 2, 72, -44, 42, 98, 1, 25, -10, -18, -21, -92, 94, -128, -6, 7, -103, 21, -56, -38, 108, 127, -110, 127, -27, 10, -76, -40, 87, -47, -45, 42, -35, -60, 48, 27, 10, 4, -43, 5, -60, -44, -68, -128, 20, -77, -128, 13, -31, -108, -56, 8, 44, -63, -12, 17, -88, -75, -99, -72, 72, 16, -119, -2, -87, -128, 9, 1, -128, -90, 14, -82, 28, -27, -80, -33, 7, -27, -69, -114, 45, -109, -7, -26, -5, -10, 6, -102, -125, 68, -58, -24, -41, 14, -41, 26, 36, -112, -94, -82, -72, 11, 9, -75, -106, 5, -28, -128, -68, 13, 6, -27, -19, -64, -121, 10, -62, -31, -56, -79, -36, 71, -90, -73, 73, -67, -98, 56, -1, -79, -128, 13, 4, -67, -63, -77, -22, 19, -19, -106, -34, 7, -81, -83, -16, -101, 7, -20, -98, 1, 19, -47, -87, -128, -7, -58, -83, 4, -44, -62, -1, -79, 29, -95, -1, 12, -4, -73, -86, 7, -128, -89, -18, 4, -87, 36, -11, -83, -75, -93, 9, -116, -12, -12, -121, -18, -20, -40, -65, 19, -45, -31, -12, -95, -39, -40, -2, -29, -83, 40, -97, -20, -116, -5, 45, -43, -128, 10, 39, -124, -83, 36, -50, 1, -33, -67, -128, 89, -31, -47, 36, 55, -128, 5, -53, -9, -20, 12, -83, -51, 36, -99, -65, 5, -93, -73, 11, -2, -46, 17, 65, -128, -66, 26, -67, -29, -4, -86, -112, -40, -28, -89, -69, -73, -111, 92, -72, -35, -36, -109, -39, -10, -19, -28, -128, -73, 46, -102, -83, -7, 7, -17, 25, -4, 1, 2, -80, -80, -56, -29, -50, -24, -65, -45, -71, 17, -116, 12, 28, -24, -7, -103, -102, 29, -68, -124, 93, -35, 41, -128, -73, 41, -77, -56, -108, -50, -43, -77, -24, 7, 5, -28, -3, -55, -89, -45, -27, 3, -9, -44, -98, -128, -36, -33, -73, -41, 1, 75, -55, 36, -34, -102, 19, -29, -77, 41, -41, -128, -9, 5, -53, -100, 18, 43, -24, -35, 17, -81, -22, 14, -111, 16, -100, -83, -43, -46, -117, -11, 55, -62, -59, 63, -99, -80, -16, -69, -73, 58, -60, 1, -19, 12, -65, 20, -12, -81, -36, -13, -128, -92, -36, 20, -26, -7, -60, -67, 11, -3, -117, 11, 92, -11, -26, -34, 35, -107, -12, -46, -110, -7, 10, -39, 8, -26, 5, -52, -14, 13, -83, 60, -11, -81, -77, -105, -92, -34, -50, -16, -20, 36, -73, -5, -1, -106, -69, -87, -11, -100, 41, -119, -56, 16, -101, -111, -98, -72, -124, -101, -1, 3, -68, -7, -89, -128, 58, 6, -36, 19, -32, -83, -80, -18, 3, -32, 29, 55, -72, 53, -58, -97, -52, -98, -44, 92, -2, -17, 58, -17, -101, -91, -13, 80, -128, 16, -59, -91, 7, -3, -94, 62, -4, 18, -16, 47, -80, -62, -46, 45, -128, -33, 59, 5, 24, 17, -65, 25, -88, 5, 18, 9, -90, -83, 12, 2, -73, 35, 52, -58, -11, -27, -29, -36, -82, -43, 6, -24, 20, -3, -25, -109, -99, -33, 55, -41, -68, -8, -128, 16, -108, -58, -20, 3, -27, -22, -3, -128, -128, 6, 82, 12, -2, -46, -128, -80, 8, -10, -6, -33, -55, -10, 35, -33, 1, 88, -41, 47, -7, 36, -68, 7, -109, -81, -7, -5, -41, -112, 28, 29, -83, 45, -56, -71, 28, -114, -73, 50, -73, -33, 3, 66, -6, -8, -5, -81, -110, 9, 73, -113, -13, -123, -44, -9, -8, -89, 29, 31, -83, -90, -36, -22, -75, 67, -1, -56, -45, 69, -52, -31, 33, -26, 87, 20, -75, -36, -41, 36, -28, -1, 6, -34, 43, 29, -67, 69, -88, -64, -36, 14, -95, -32, -10, -92, -47, 8, 28, -81, -46, 72, -67, -51, -69, -77, 20, -89, -73, -81, 10, -64, -119, 34, -18, -128, -20, 32, -18, 4, -53, -64, 34, 50, -4, -12, 29, -53, -77, 33, -25, -94, -47, 9, -95, 39, -128, -128, -12, -16, -89, -27, -34, -55, -8, 20, -3, 34, -2, 18, -58, -50, -41, -35, 41, -80, -102, -103, 14, 25, -51, -16, -34, -19, 40, 1, -89, 28, -83, -128, 25, 16, -36, -28, 28, -36, -65, -29, 14, -113, 2, -62, 17, 36, -56, -87, -73, -27, -72, -93, 8, -63, -63, 92, -1, -123, 7, -110, -1, -20, -44, -73, 7, -32, 11, -92, 16, -26, -71, 4, -31, -10, 82, -79, -90, 24, -36, -50, -13, 60, -63, -63, -87, -79, -9, -2, 17, -36, 6, -34, -17, 41, -77, -41, 9, 22, -16, -20, -5, -102, -100, 36, -14, -50, -91, 55, -34, -33, -81, -128, 4, -19, 1, 31, -2, -86, -71, -29, -58, -79, -71, -25, -66, -18, -9, -128, 32, -26, -127, -25, -24, -107, -92, 26, 33, 3, -5, -18, -33, 12, -95, -64, -41, -47, -80, -113, -55, 9, -63, -90, 28, -32, -16, -77, -31, -75, -69, -91, 22, -7, 83, -55, 50, 29, -102, 33, 20, 20, 25, -128, -68, 10, -113, -36, 77, -89, -79, -18, 16, -6, -101, 19, 77, -62, -35, -44, -99, 1, -33, -128, -28, 24, -69, -87, -39, -35, -73, -27, 16, -11, 9, -28, -47, 17, -62, -87, 27, 45, 11, -33, 56, -99, -64, 29, -16, -98, 4, -22, -41, 89, -128, -41, -27, -1, -113, -90, -25, -31, -50, 47, 16, -11, -51, -80, -65, -82, -53, -89, -12, 64, -83, 11, 33, 19, -123, 72, -4, -110, -6, -32, -92, -8, -86, -40, 55, 1, -91, -2, 35, -24, -117, 16, 35, 6, -35, 60, -128, -73, -94, -128, -4, -11, -128, -36, -1, 93, -128, 33, -26, -83, 40, -128, -98, -36, -83, -128, -22, -16, -119, -128, -10, 13, -88, -6, 44, -5, -26, -6, -65, 36, -69, -36, -58, -82, -28, -128, 59, -59, -128, -16, 36, -102, -58, -53, -53, 72, -62, -105, -41, 36, -56, -107, 4, 18, -26, -31, 45, -46, -73, -1, -5, 33, -128, -114, 19, -14, -29, -100, 5, -12, -27, -31, -68, -89, 2, -128, -128, -6, -68, -125, 27, -7, 73, -75, 31, -93, -43, -14, 28, -79, -79, -20, -119, 26, -102, -39, -44, 3, 40, 6, 43, -113, -58, -55, -58, -71, -27, -9, -128, 13, -11, -128, 50, 56, -75, -35, -64, -82, -87, 73, -75, -86, 65, -128, -60, 17, -83, -82, -2, -59, -79, -86, -28, 39, -16, 13, -11, 24, -44, -64, -100, 31, -43, -87, 50, -128, -28, -128, -50, 83, -51, -63, 7, 62, -3, -128, -36, 32, -47, -72, 66, -19, -12, -77, -51, -71, -2, 53, 12, -112, 22, -94, -17, -36, -89, -13, -41, -66, -8, -82, 25, -27, -89, 12, -44, -59, 24, -56, -66, 86, -62, -34, 71, 11, -29, -52, 6, 55, -80, 20, -7, -128, -9, -77, -56, 9, -13, -128, -34, 13, -41, -67, -1, -55, -101, -2, -24, -80, -114, -87, -41, -50, -122, -34, 60, -8, 59, -11, 69, -110, -40, 39, 79, -80, -45, -80, -75, -62, 6, -72, -45, -19, -9, 13, 27, -109, -97, -50, -14, 73, 12, -32, -92, 2, -55, -128, -3, -55, -83, -128, -81, -26, -43, -77, -13, -89, -41, -128, -100, 9, -128, -101, -19, -86, -105, -40, 52, -11, -39, -25, -89, 52, 20, -27, -83, -17, -62, -102, 9, -60, -50, -108, 4, 6, -98, -32, 77, -56, -13, -128, -128, 6, 20, -53, 20, -71, -82, -103, 8, 87, -92, -91, 1, -17, -12, -33, -128, -22, -128, -5, 63, -68, 16, -22, 72, 28, -66, 3, -14, -80, 11, -60, 19, -64, 2, 16, 5, -62, -90, 1, 10, -22, -43, -28, -58, -103, -83, -52, -83, 41, -97, -62, 11, 82, -16, -43, 14, -33, -20, -60, 20, -25, -36, -53, -19, 40, -81, -58, -18, 20, -44, -39, 20, -119, -41, -112, 36, 52, -59, -8, -62, 68, -81, 19, 32, -80, -128, -40, -124, 13, -17, 47, -13, -5, -8, -114, -64, 13, -56, -41, 28, -16, -51, -89, -68, -41, -128, -35, 16, -81, 50, -62, -103, 20, -33, -51, -1, -123, -117, -112, 3, 16, -56, 14, 14, -19, 13, -128, -36, 75, -32, 73, -45, -41, -83, -128, -20, 67, -46, 17, -60, -128, -71, -88, 17, -2, -91, -10, -47, -113, -128, -59, -19, -73, -111, 60, -12, -115, -82, 11, -92, 56, 7, 18, -41, -82, -53, -77, -80, -31, -79, 47, -1, -62, -88, -90, -41, 3, -47, 26, -41, 25, -3, -110, -25, -128, -31, -11, 51, -16, -99, -50, -88, -50, -58, -41, -31, -26, 19, -101, 20, -53, -99, -32, 46, 28, -19, 75, -36, -94, -111, -121, 92, -81, -128, -8, -34, 11, -24, 39, 32, -32, -62, -64, -114, 8, -64, 13, 25, -75, -93, -73, 67, -16, -123, 12, 8, -7, -97, -34, -83, -12, -91, -1, 68, -56, 41, -41, -19, 39, -91, -52, 36, -7, -50, -121, 2, 24, -79, -36, -8, -89, -75, -77, 6, -5, -63, -6, 89, -56, 27, -60, -101, -35, -89, 36, 77, -63, -87, -68, 13, -3, -124, 71, 27, -128, -50, -33, -14, -66, -100, -77, -27, -68, -1, -24, -29, 44, -93, -32, 10, 4, 1, -128, -77, 7, -72, -43, 13, 59, 8, -52, 20, -24, -69, 36, 16, -41, -66, -128, -82, 29, -128, 29, 4, -44, 75, -107, -11, -86, -73, -124, 27, 46, 68, 27, 64, -1, -9, 15, 7, 22, 30, 15, -60, -13, 35, 1, 45, 36, 72, 35, 37, -74, 35, 5, 15, 28, 55, -10, -85, 1, 28, 10, 5, 28, 60, 44, 28, -41, 34, 23, 1, 38, 28, 12, -64, 1, 43, -9, 13, 20, 36, -22, 5, -76, 17, 43, -20, 22, 57, 72, -20, -23, 28, 13, 50, 17, 9, -105, 15, -48, -4, 4, -23, 27, 43, 37, -10, 32, 43, 10, 60, 9, -1, -90, 20, -74, 12, 28, -20, -12, 25, 10, 5, 32, -5, 34, 32, 52, -5, 127, 34, -36, 7, 61, 20, -68, 30, -35, 20, 10, 9, 27, 17, 44, 36, 4, 55, 3, 27, 45, 3, 68, 55, -100, 20, 28, 43, 35, 60, 28, 64, 32, 37, 10, 12, 15, 43, 71, 27, 1, 89, -37, 13, 34, 36, 7, 105, 88, 15, -13, 25, 10, 34, 57, 1, -10, 105, -32, 23, 17, 34, 41, 92, 127, 22, -4, 20, -7, 54, 72, -5, -4, 27, -52, 20, -32, 2, 35, 44, -43, 45, -38, -10, 12, 1, 10, 22, 94, 38, -44, 48, -83, 34, 45, -5, 44, 36, -23, -34, -1, -20, 44, 10, 60, -43, -30, 41, -68, 7, 43, -60, 12, 17, -41, 13, 20, -9, -1, 32, 77, -36, 7, 25, -85, 34, 34, 30, -23, 48, -3, 2, 20, 22, -35, 45, 48, 1, 20, 36, -34, 44, 17, 27, 2, 32, 3, -2, 27, -2, -55, 28, 7, -5, -5, 12, -22, 15, 2, 65, -64, 34, 25, 60, 7, -7, 77, 5, -1, 84, -4, 36, 54, 13, 28, 94, -32, 61, 37, 57, 22, -12, 87, 44, -50, 127, -52, 4, 28, 9, 23, 71, 88, 30, 89, 68, -1, -10, 52, 30, -1, 92, -104, 17, -61, 27, 23, 55, 4, 35, 46, 83, 1, 28, 71, 64, 38, 55, -43, 28, -79, 45, 22, 72, -3, 5, -22, 15, 3, -9, 90, 50, 96, 44, -41, 20, -82, -1, 12, 15, 28, 64, -17, 37, 5, 2, 121, 30, 61, 30, 13, 34, -89, 7, 13, 13, 32, 10, -22, 15, 38, 1, 88, 37, 41, 32, 12, 48, -3, 1, 36, 10, -4, 28, -4, 52, 22, 27, 32, 28, 9, -128, 60, 30, -15, 60, -20, 71, 10, 36, 28, 22, 30, -15, -3, -5, 28, 112, 36, 30, 83, 7, 23, 122, 17, 61, 38, 54, 34, -5, 1, 23, -23, 127, -70, 1, 38, 52, 22, 65, 90, 28, 88, 50, -9, -10, -2, 2, -1, 84, -50, 23, -43, 12, -23, 34, -3, 25, 48, 61, -5, -4, -98, 4, 32, 60, -54, 50, -61, 5, -15, 71, -28, 4, 2, 46, -25, 22, -89, 17, 52, 65, -85, 65, -128, 17, 27, 55, 17, 34, -48, 61, 28, -22, 1, 13, 41, 7, -48, 46, -108, 23, 43, -4, 36, 28, -12, 48, 17, 32, 127, 41, 68, 44, 28, 15, -30, 36, -3, 13, 37, 28, -27, 4, 38, 32, 127, 17, 27, 44, 25, 36, -1, 17, 4, -48, -34, 50, -1, 7, 45, -4, -34, -15, 50, -43, 17, 20, 105, 43, 25, 22, 36, 17, 13, -13, 55, 28, -50, 28, -17, -15, 22, 3, 94, 36, 45, 41, 30, 79, 48, -3, 28, -9, -77, 30, -37, 74, -64, 44, 68, 7, 10, 5, -30, 20, 43, 52, 25, -7, -54, 20, -37, 32, -85, 23, -3, 12, 9, 5, -114, 44, 3, 36, 2, 27, -10, -15, -12, 5, -118, 36, -128, 1, 34, -22, -128, 28, -87, 45, 41, 5, 46, -27, 1, -23, -68, 48, -128, 52, 35, -43, 9, 1, -76, 32, 46, 27, -20, 5, 17, 34, 5, 32, -71, 45, 13, -2, 25, 45, -9, 30, 52, 9, 74, -5, -52, 37, 27, 44, 13, 20, -2, -60, 89, 17, -20, -28, 4, 5, 41, 1, 76, -128, 95, 52, 88, 28, 20, -50, 127, 2, 27, -68, 27, -12, 2, 4, 55, -122, 76, 15, 85, 10, 37, -3, 44, 50, 15, -60, 41, 10, 4, 3, 55, -17, 4, 4, 105, 1, 41, -37, -17, 10, -35, 7, 55, -9, 1, 30, -9, 82, -72, -1, 55, 41, 50, -70, -44, 38, -70, 5, 20, 10, -25, -17, -28, 36, -108, 28, -36, 38, 28, -76, -13, 25, -128, 23, 28, 15, -7, -7, -35, -28, -85, 45, -119, 10, 10, -84, -1, 10, -121, 37, 44, 12, -15, 2, 5, -94, 12, 32, -87, 9, 25, -46, -10, 28, -46, 13, 74, -12, -41, 5, -83, -79, -13, 57, -3, 15, 15, -46, -3, 25, -46, -7, -2, -1, -55, 44, 88, -109, 92, 57, 22, 12, -3, -76, -34, 13, -60, -48, 30, -2, 9, 10, 64, -128, 127, 28, 46, 22, 41, -35, -17, 25, -94, -52, 44, -7, 27, 30, 105, -128, 94, 32, 119, 36, 15, -60, -122, 17, -126, -35, -13, -13, 12, 38, 46, 5, -55, 46, 44, 2, 30, 1, -88, 23, -113, -35, -1, 2, 2, 4, -25, 109, -106, 15, -13, 20, 41, -61, -44, 57, -128, 2, 23, 1, 3, 30, -70, 17, -94, 1, -128, 38, 25, -119, 34, 52, -128, 4, 61, 7, 32, 28, -4, -128, -28, 15, -109, 46, 12, -99, 30, 28, -89, 3, 30, 22, -27, 54, -55, -128, -15, 37, -41, 12, 2, -35, -1, -13, -45, 10, -5, 7, -28, 9, 32, -94, 54, 23, -48, 3, 44, -32, -87, 1, -54, -17, 17, -23, -4, 27, 27, -105, 25, 55, 55, 44, 28, -5, 5, 46, -57, -25, -7, -10, -1, 25, 82, -71, 28, 36, 84, -3, 36, 15, -105, 17, -57, -36, 1, -13, -43, 43, 64, -27, -35, 22, 84, 22, 25, 55, -92, 27, -68, -34, 22, 1, -52, 41, 2, 50, -72, 30, -34, 28, 25, 48, -20, 28, -128, -12, -4, 17, -76, 72, -7, 114, -83, 37, -128, 34, 22, -30, 22, 32, -117, 12, 7, -15, -41, 23, -35, 30, -13, 44, -128, 64, 32, -20, 17, 45, -48, 1, 27, -2, -128, 43, 28, -128, 28, 20, -64, 37, -28, -12, -27, 34, -46, 57, 38, -4, 68, 13, -15, -57, -96, 7, -13, 55, -13, 2, 27, 13, -41, 46, 3, -10, 23, 36, 30, -76, -38, 35, -45, 13, 32, 23, 20, 23, -41, 22, 27, 5, 10, 37, 20, -27, -3, 38, 36, 41, -1, 28, -52, 45, -7, 30, 23, -12, -15, 22, -4, -28, 2, 60, 3, 37, 28, -3, -82, 45, 22, 60, 17, -7, -25, 41, -1, 3, 9, 54, 34, 34, -4, 82, -61, 28, -17, 71, 28, 12, -32, 30, 12, 36, -55, 35, -72, 28, -1, 72, 7, 55, -77, 34, 22, -1, -90, 43, -55, 60, -5, 43, -128, 41, 20, 38, 23, 37, -15, 55, 5, -4, -87, 34, 13, -128, 2, 17, -76, 15, -27, 1, -23, 37, -44, 22, 35, -15, 50, -2, -23, -44, -126, 30, -38, 32, 1, 3, 34, 28, -60, 28, 28, 4, 34, 27, 28, -37, -128, 15, -61, -2, 25, 20, -55, 57, -37, 36, 44, -20, 68, 7, 4, -28, 9, 34, -64, 10, 3, 28, -48, 4, 20, 36, 52, 3, 20, 37, -5, -17, -12, 43, 2, 4, 41, -4, 1, 5, 50, 48, 23, 1, -2, 4, -9, -34, -10, 25, -7, 20, 34, 10, 45, 17, 76, 38, 27, 2, 4, 55, -3, -71, -68, 30, -72, 2, 20, 32, 17, 45, -9, 12, 37, -23, -4, 54, -15, 22, -12, 52, -128, 61, 28, 12, 44, 48, 22, 27, -3, -5, 1, 1, 1, -30, 12, 23, -88, 30, 20, 35, -22, 32, -48, 35, 9, 1, 25, 12, -17, 1, -119, 25, -32, 38, -5, 38, 45, 44, -61, 4, 34, 15, 60, 36, 3, 10, -122, 28, -61, 38, 7, 35, 112, 28, -34, 30, 37, -13, 10, 30, 2, -15, -32, 48, -74, 13, 28, 13, -23, 44, -9, 17, 55, -44, 17, 7, 9, -5, 17, 44, -44, 36, 20, -45, 2, 32, 27, 27, 44, -22, 23, 23, 5, -74, -35, 37, -28, 12, 28, -27, 52, 38, 17, 12, 55, -5, -84, 48, -35, -128, -25, 1, -2, 22, 36, -48, 34, 4, -9, 44, 13, 38, -46, 45, 4, -118, -4, 15, -128, 52, 20, -9, 1, 37, -17, -7, 3, 30, 87, 23, -1, -37, 3, 17, -54, 20, 7, 4, -30, 60, -1, 28, 36, 2, 34, 34, -20, -22, -92, 32, -5, 34, -17, 46, -7, 50, -20, 13, 5, -1, 50, 27, 10, 7, -90, 17, -65, 30, 9, 5, 25, 13, -32, 65, 23, -13, 108, 1, 1, 12, -41, 28, -54, 22, 28, -4, -2, 25, -4, 54, 2, -36, 25, 7, 2, -37, 9, 52, -46, 3, -12, -52, -85, 23, -23, 23, 1, -41, 25, 23, 44, -57, 7, 44, -43, 36, -10, -76, -61, 1, -50, 30, 3, -41, 22, 10, 10, -100, -20, 17, 2, 35, -41, -92, -117, 57, -28, 4, -3, -28, 70, 7, -15, -115, 2, 22, -85, 22, 9, -7, 41, 46, -28, 5, 10, -55, 57, -15, -36, -98, -28, 28, -32, 9, 1, 59, 38, 9, -41, 90, 3, 1, 28, 28, 32, 1, -38, -24, -33, 8, 13, 48, 49, 11, -37, 90, 48, -2, 1, 66, 8, -57, -20, 37, -43, 1, 11, 6, 67, 1, -19, -8, 22, 13, -3, 20, 24, -38, -12, 1, 12, 2, 1, 1, -34, 3, 20, -22, 63, -11, -48, 20, -20, -43, -1, -11, 8, 6, -8, 3, -128, 2, 2, -37, 1, -1, -32, 38, -43, 19, -35, -9, 20, -3, 12, -56, -128, 1, -1, -1, -6, -6, -63, 33, -49, -9, -22, 3, 6, 24, 3, -81, -119, 9, 2, 13, 1, 6, -59, 24, -66, 8, 8, 3, -2, 2, 11, -35, 6, 19, 34, 16, -20, 2, -70, 24, -126, -9, -16, 20, 1, 3, 11, 97, -12, 33, -9, 48, -16, -2, 28, 1, -32, 53, -16, -115, -1, 11, 13, 91, -22, 37, -16, 97, -78, 20, 8, 24, 2, 70, -6, 47, -20, -24, -1, 37, -128, -2, -12, 91, -47, -6, 35, 45, 83, 63, 32, -69, -38, 12, -19, 32, -128, -20, 2, 19, -1, -2, 43, 55, 109, 24, 12, -75, -16, 32, -9, 33, -125, -32, -37, -43, 32, -3, 19, 63, 51, 24, -1, -16, 16, -3, 12, 3, -107, -6, -24, -67, -8, -9, 9, 45, 6, 3, -32, -16, -11, 13, 20, -6, 1, -34, -24, -12, 6, 1, -3, 2, -38, -16, -9, -1, -8, 20, -8, -24, -1, 20, 6, -38, -33, 16, -16, 24, -49, 2, 1, -12, -6, -1, 1, 92, 56, 41, 37, 45, 78, -13, 19, 13, -41, 6, -124, 12, -20, 20, -6, 97, 9, 12, 24, 32, -6, -8, 99, 16, -49, 53, -128, 1, -107, -16, 2, 67, 37, 47, 22, 63, -11, 6, 76, -8, 33, 53, 32, 51, -76, 24, 1, -37, -43, 13, -12, 72, -16, -1, 37, 34, 13, -6, 43, 1, -95, 12, 6, -55, -12, -55, 16, 2, -47, -16, 6, 37, -37, -9, -16, -16, -41, 11, 2, -47, -6, -128, 13, 8, -37, 3, -24, -12, -9, 16, -11, 9, -35, -2, -1, -1, 12, -38, 12, 16, -2, 8, -104, 20, -67, -19, 2, 13, -24, 1, 3, -43, 9, 6, 24, -9, -20, 24, -105, 37, -48, -128, 20, -1, 6, 1, 8, 12, 51, 47, 2, 115, 109, 2, 47, 38, -24, 33, -113, -20, 16, -13, -6, -32, 49, 63, 20, 101, 41, 1, 47, 48, -43, 49, -109, 20, -20, -22, 12, -126, 63, 115, -13, 96, 56, -11, 19, 9, -35, 35, 1, -48, -13, 9, 16, -128, -11, 91, 19, 92, 1, -8, -8, 108, 19, 41, 56, -19, -37, -12, 12, -128, 12, 12, 28, 22, -6, -13, 37, 6, -125, 13, 24, -19, 12, 19, 6, -87, -90, -47, -2, 20, -8, 6, 78, -33, -104, -20, -2, -8, 12, -1, -1, 49, 9, -35, -8, 12, 19, -1, 38, 32, -128, -43, 11, 20, 1, -1, 8, 32, 16, -1, 20, -12, -38, 3, -48, 20, -24, -28, -3, -9, 19, 12, -2, 81, 57, 2, 9, 90, 22, -19, 76, 41, -43, 20, 20, 66, 34, 32, -9, 104, 70, -3, -2, 95, 95, -13, 99, 55, -13, 59, 57, 47, 1, 20, -2, 73, 83, 83, 2, 72, 109, 8, 113, 19, 20, 73, 13, 2, 38, -8, 11, -34, 33, 125, 2, 108, 8, -12, 28, 97, 69, 28, 19, -8, 22, -6, 9, -43, 2, 127, 32, 119, -9, 9, 43, 20, 57, 20, -3, 6, 35, 1, -6, 101, 104, 63, 12, 37, -20, 11, 38, 35, 41, 24, -12, -8, 22, 3, -2, 127, -1, 63, 20, 2, 3, 3, 91, 57, -24, 11, -20, 24, 6, 8, 1, 83, -1, 38, 1, -33, -63, 1, 24, 55, 127, 6, -22, -11, 13, 20, 8, 125, -53, 90, 67, 95, 108, -9, 34, -6, -34, 66, 16, 1, 33, 20, -12, 127, 13, 56, 28, 81, -9, -2, 47, 34, 6, 41, 1, -33, 12, 16, -1, 124, -37, 12, 24, 67, 16, -16, 48, -1, 57, 38, -6, -67, 19, 20, 12, 69, -85, 16, -3, 35, 32, -3, 37, 45, 113, 24, 8, 20, -8, -6, 1, 56, -43, 41, 49, 48, -32, -2, 45, 51, 101, -2, 12, 9, 70, -1, 16, 87, 47, 28, 75, 67, -59, -6, -1, 33, 72, 35, -2, 20, 45, -6, 12, 115, -13, 37, 69, 70, -20, 12, 1, 57, 37, 72, -19, 51, 12, -3, 12, 113, -1, -11, -9, 81, -78, 3, -2, 45, 101, 113, -9, 127, 12, 13, -16, 115, 59, 127, 105, 109, 107, 1, 12, -22, -70, 41, 24, 3, 24, 9, -16, 119, 125, 78, 90, 99, 16, 11, -1, -37, -2, 83, 20, -11, 9, 11, -13, 104, 20, 63, 92, 91, 3, -1, -6, -56, -19, 78, -56, 51, 12, -9, -1, 66, -16, 20, -1, 67, -24, -19, -2, -87, 70, 19, -38, -24, -1, -19, -3, 66, 9, -9, 16, 43, -11, 2, 20, -24, 92, -13, 6, 13, 55, -8, -11, 97, -33, 22, 35, 22, -2, -9, 53, -16, 95, -57, 20, 47, 127, 1, -8, 105, -6, 43, 19, -24, 20, 11, 48, -8, 8, 109, 19, 59, 76, -3, 9, 113, -11, 6, -1, 95, -41, -20, 53, -20, 47, 113, 6, 63, 38, -33, -22, 57, 91, 34, 69, 45, 121, 1, -24, -33, -107, 2, 38, -1, 127, -32, -6, 75, 95, 53, 104, 70, 32, 2, -33, 11, -49, 20, 22, -6, 53, -13, -8, 55, 85, 69, 76, 76, 43, -1, -34, -91, -73, 55, -69, 33, 1, -12, -20, 37, -8, 38, 3, 105, -13, -6, -47, -115, 37, 22, -16, -1, -9, 3, 22, -16, -9, -1, -12, 53, -22, 3, -1, -87, 76, -2, 20, 9, 57, -2, -3, -95, -20, -32, -37, 8, 13, 2, 95, -92, 107, -34, 9, -24, 119, 1, -13, -8, -6, 9, -20, -73, 119, 2, 67, 11, 12, -43, 20, 20, 109, -2, -2, 13, -3, 12, -20, 35, 67, -3, 97, -24, -91, 121, 20, 19, 49, 13, -1, 47, 12, -8, 24, -56, 69, -9, -20, -75, -24, -63, 127, 72, 99, 1, -6, 70, 20, -48, 33, -45, 55, 11, 6, -49, -51, -24, 35, 70, 124, -11, 2, 53, 43, -63, 43, -11, 81, 6, 55, -83, -2, -19, -51, 20, 73, 12, -19, 67, 73, -24, -69, 69, -32, 3, 73, -72, 1, 9, -97, -1, 20, 2, -6, 16, 75, -57, -87, 63, -49, -2, 83, -66, 92, -33, -41, 24, 2, -6, 1, -67, -20, -107, -109, 3, 11, -2, 121, -53, 59, -104, -22, 28, -11, -9, 12, -41, -9, -75, -67, -81, 127, 8, 127, -16, 81, -90, 28, -6, 75, -3, 6, -11, 6, 13, -69, -128, 113, 3, 57, 12, -20, 24, -8, -6, 47, 6, -2, -28, -47, 28, 34, -57, 35, 2, -22, -49, 78, -41, 95, -20, 45, 9, -9, 8, -32, 41, 66, -92, -19, 6, -1, -49, -63, -22, 75, 35, 95, -19, -1, 35, -2, 47, 11, -85, -3, -2, 24, -28, 43, 13, -47, 6, 81, -12, 1, 2, 41, 97, -38, -22, -3, -16, 3, -38, 24, 38, -67, 6, 1, 1, -1, 45, 6, 107, -57, 33, -92, -9, 24, -55, 9, 24, -83, 20, -1, -3, -8, -2, 34, 108, -104, 49, -38, -11, 70, -13, 49, 11, -59, -41, -16, -2, 2, -41, -1, 2, -78, -8, 38, -6, 127, -76, 78, -56, 22, 34, 91, 3, -19, -66, 16, 28, -95, -57, 127, -9, 127, 16, 37, -95, 1, 12, 2, 2, -6, -24, 51, -32, -13, -75, -3, -1, -34, -24, 92, -70, 105, -43, 67, 8, 1, -43, -2, 1, 19, -85, 19, -9, -41, -1, 85, -28, 107, -113, 91, -11, 6, 24, 2, 34, 16, -69, 34, -1, -24, -9, 13, -19, 8, -45, 76, 13, 3, 28, 90, 76, -20, -34, 34, -11, -3, -8, -3, 20, -91, 6, 67, 8, 9, 66, 24, 109, -19, -22, 24, 1, 9, -24, -85, 35, -125, 6, 6, 11, -2, 70, 87, 127, -59, 55, -20, 19, 69, -22, -48, 96, -109, 11, -48, -1, 1, 24, -1, 125, -33, 38, -3, 12, 127, 1, 24, 91, -19, -20, 45, 1, 19, 1, 3, 19, -24, 55, 127, -16, 127, 48, 59, 101, 22, -1, -47, -11, 16, -16, -34, -43, -24, -47, -38, -12, -24, -22, 69, -49, 125, 20, 47, -9, -13, 11, 1, -48, -24, -75, -53, 11, -73, -16, 91, -12, 101, 16, 66, -13, 1, 24, 38, -28, -8, -70, -12, -20, -75, -6, 67, -3, 87, 72, 75, -12, -16, 22, 55, 9, -43, -69, -12, -13, -63, 9, -19, -19, -90, -43, 48, -2, 8, 101, 115, 57, -24, -49, 16, 16, -104, -8, -73, 28, -121, 33, 34, 2, 8, 127, 127, 127, -16, 3, 48, 33, -53, 53, -72, 56, -128, 90, -67, 2, 2, 127, 127, 72, 38, 49, 59, 38, -53, 20, -1, 95, -73, 125, -38, -1, -16, -2, 41, 127, 43, 83, 127, 13, 6, 38, 85, 123, 13, 101, -72, -7, 17, -83, 2, 18, 20, -90, 5, 5, -127, -23, 62, -44, -72, -10, 1, 1, 24, -82, -48, -8, 47, -109, -34, 28, -84, -18, 25, -25, -18, -28, -16, -2, 11, -89, -52, -2, 63, -80, -25, 20, -67, 8, -128, 12, 18, -12, 34, 2, 15, -128, -35, 5, 71, -17, 1, 37, -38, -24, -89, 35, 37, -1, 18, -23, 15, -128, 34, -15, 57, -28, 37, 30, -37, -4, -11, -8, -2, -4, -16, -5, 19, -128, 65, -10, -7, -28, 35, 24, -62, 20, 65, -17, -1, 1, -3, -3, 8, -96, 104, 5, 19, -18, 38, 10, -122, 25, 89, -3, 58, -11, 35, 13, 24, -77, -8, 1, 44, -25, 69, -12, -95, 5, -128, -16, 61, 2, 30, 11, 4, -111, 24, -32, 25, -61, -73, 11, -61, -11, 106, -90, -95, -1, -24, 8, 2, -119, 51, -8, 19, -72, -50, 26, -72, -16, 69, -48, -102, -19, -18, 8, 11, -75, 47, -10, 57, -72, -40, -19, -38, 27, -26, -15, -4, -2, 11, -13, 25, -17, 61, -3, 20, -52, -25, 34, -58, 10, -114, -1, 5, -11, 11, 8, 24, -42, 99, -13, -19, -44, -2, 24, -24, 2, -44, -48, -36, -5, -17, -11, 17, -114, 113, -3, -30, -62, 15, -18, -7, 17, 1, -1, -3, -1, -77, 4, 10, -122, -2, 18, -37, -48, 23, 11, -80, -13, 52, 7, 58, -16, -23, -8, 11, -66, 1, 15, 11, -36, 93, 2, -27, -4, -11, -13, 69, -32, 65, -15, -1, -54, -128, -26, 27, 1, -91, 1, -28, 41, 69, -63, 44, 5, 25, 11, -3, -99, -109, -23, 17, -40, 4, 15, -123, -1, 11, -58, 90, 11, 58, -16, 15, -102, -97, -5, 38, -52, 30, -11, -128, 41, 17, -58, 13, 18, 72, -12, 7, 4, 48, 8, 65, -2, 1, -7, -128, 69, -4, -34, -26, -3, -42, -8, 36, -16, -30, -17, 30, 8, 11, 5, -126, 34, -34, 36, -20, -11, -63, -8, 2, -79, 7, -5, -1, 12, -5, 10, -105, 61, -3, 24, -44, -4, -82, 12, 25, -114, -10, 2, -12, 34, -19, 11, -37, 13, 51, -90, 19, -13, -58, 10, 13, -107, 24, 10, 23, -61, 69, -41, 25, -5, 58, -128, 63, 7, -16, -19, -19, 26, -128, -32, 67, -19, -35, -12, 30, 37, 58, -1, 8, 1, -27, -18, 19, -24, -84, -12, 27, -10, -23, -30, 1, 34, 71, -4, -30, -19, 15, 2, 18, 15, -80, -16, 27, -20, -23, 11, -38, 38, 47, -61, 44, 15, -30, -8, 20, 26, -90, 7, 88, -26, 1, -1, -65, 58, 13, -69, -1, -23, 24, -13, 34, 80, -23, 12, 90, -8, -5, -8, -94, 48, 40, -16, -15, -1, -16, -16, 15, 127, -69, 8, 26, 10, 1, -2, -94, 66, -41, 57, -58, 12, -104, -5, 17, 42, -18, -4, -11, 67, -20, -7, -61, -4, 57, 104, 2, -1, -109, -12, 3, 58, 5, 1, 44, 19, 23, -20, 97, 11, 84, 1, 58, 3, -11, -8, -18, 89, -124, -15, 73, 77, 7, -10, 79, 61, -23, 63, -19, 1, -1, -24, -11, 80, -94, -17, 41, 66, -34, -20, -7, 48, 42, 69, -48, 10, -35, -30, 19, 30, -111, -23, 38, 20, -32, -15, -57, 8, 80, -13, 30, -4, -80, -20, 27, 3, -90, -10, 105, -25, -11, 15, -128, 37, 62, -50, -13, -5, -16, -18, 12, -24, -11, 23, 104, -50, -27, 13, -66, 36, -18, -65, -52, 15, 4, -15, 25, -30, 82, 19, 113, 5, -4, 1, -28, 79, -94, -27, -109, -1, -88, 12, 1, -128, 2, -13, 88, 58, -40, -8, -12, 17, -48, 28, -48, 1, -128, -1, 19, 5, 5, 36, 67, 72, -2, 12, 74, -10, -123, 67, 48, -11, -71, -34, -26, 91, -4, 7, 90, 107, -11, -35, 41, 16, 30, 99, -48, -16, 15, -11, 12, 127, -128, -13, 61, 105, -4, -3, 50, 47, 38, 90, -40, -2, 3, -18, 4, 57, -60, -25, 15, 90, -24, 12, 10, 34, 110, 37, -19, -3, -18, 4, 18, 15, -40, -23, 58, 34, -4, 10, -42, -2, 97, 44, -7, 13, -8, -24, 11, 24, 1, 2, 40, -34, -10, 1, -28, 23, 48, -24, -25, -1, 8, -2, 15, 7, 44, 20, 57, -34, -15, 19, -40, 35, -24, -73, -93, -23, -82, -8, 23, -61, -27, -4, 97, -2, -8, 7, -82, 5, -48, -73, -47, -15, -113, 3, 18, -5, 24, 27, 54, 10, 17, 20, -71, -30, -38, -37, 18, 2, -58, -12, -3, 100, 44, 66, 127, 99, 51, 12, 23, -27, 1, 36, 67, -8, 88, -24, -7, 109, 26, -2, 104, 67, -5, 23, -25, -15, 54, 80, 80, -10, 94, -42, 23, 63, -17, 13, 57, 58, -3, 8, -42, -23, 77, 54, 25, 12, 80, -18, 27, -25, -15, -24, 42, 16, -15, -5, -54, -15, 96, 2, -4, 5, 17, -16, 7, -5, 25, -17, 28, 3, 11, -12, -60, -44, 58, 12, 12, -5, 27, -17, 1, -52, 1, -5, -2, -32, 23, -1, -5, 5, 19, -26, -65, -25, -122, -27, 19, -111, 10, 7, 35, -17, 11, -4, -62, -17, -30, -99, -20, 19, -28, -32, 1, -62, 10, 7, 58, -66, 65, -10, 3, -35, -58, -123, 8, 13, 11, 2, 7, 34, 94, 8, 122, 3, 61, -25, 37, -20, -61, 12, 109, -1, 127, -18, 4, 73, 107, 1, 73, 38, 18, -12, 80, 18, -12, 27, 58, -13, 127, -23, 13, 26, 80, -11, 58, 57, 10, 17, 104, -34, -12, 32, -30, 5, 107, -5, 20, -38, 72, -5, 16, 5, -16, -20, 48, -3, -2, -2, -47, -20, 47, -8, 5, -48, 19, 3, -10, -26, -27, 4, 124, -34, 74, -16, -19, -12, 37, -17, 28, 3, 12, -18, -60, -27, -10, 8, 72, 4, 15, -16, -17, -2, -94, -12, 1, -36, -10, 3, -38, -44, 1, 2, 1, 24, 5, -18, -10, -2, -67, -18, 11, 19, 35, 12, 17, -50, 30, 5, -12, 37, 16, -111, 19, -12, 25, -1, 10, -16, 84, -17, 36, -80, 16, -19, 12, -12, -52, -50, 127, -25, 127, -2, 4, -7, 87, 5, 16, -48, 1, -8, 10, 1, -34, -28, 74, -15, 127, 8, 26, 12, 87, 24, 41, -26, 8, 1, 54, -18, -36, 2, -25, -2, 123, 7, -17, -1, 48, 3, -5, 27, -7, -5, 77, -8, -97, 16, -38, -5, 94, -19, 35, -12, 32, 34, -13, 5, -26, 4, 82, -11, -58, -18, -74, -16, 69, -7, 12, -7, 19, 8, -74, -3, -19, 2, 42, 11, 54, -28, -19, 5, -15, -25, 8, 54, 12, -10, -48, -16, 7, 5, 28, -3, 30, -57, 8, -12, -74, 8, 26, 73, 5, -1, 30, -54, 24, 8, 23, 34, 75, -20, 38, 2, 40, 3, -19, -2, 48, -18, 72, -32, 5, 1, 4, -27, 44, -58, 127, -12, 127, 2, 8, -13, 36, -12, 83, -52, 5, -10, 2, -8, -50, -17, 127, 1, 127, -5, -3, 13, -17, 19, 77, -54, 18, 11, 40, -35, -17, 3, 1, -27, 127, -8, -28, 30, -24, 8, 35, -11, -23, -3, 18, -5, -34, 44, -23, -20, 127, -5, -13, 40, 69, 7, 11, 8, -30, -16, 16, 3, -74, -3, -27, -7, 100, -3, -13, 20, 30, -1, -40, -4, -36, 12, 20, 4, -32, -13, -54, -18, 18, 2, 17, 27, 24, -3, 16, 8, -3, -19, 51, 19, 52, -58, 25, 3, -69, -5, 19, 23, 27, 7, 58, 7, 58, 2, 127, -16, 57, 1, 41, 4, 47, 11, -4, 17, 15, -25, 48, -16, -19, 13, 35, -5, 20, 19, 71, -7, 124, -3, 17, -12, 8, -23, 19, -24, -13, -5, 37, -1, 48, -5, 80, -24, 127, -1, 26, 18, 111, -4, 61, -10, 26, 5, 50, -4, 19, -19, -8, 3, 96, -26, -24, 15, 44, 35, 11, -17, 18, 16, 57, -11, -2, -25, -26, 8, 80, -26, 30, 40, 50, 3, 42, 11, 8, 1, 27, 1, -8, -13, -27, -1, 91, -32, -5, 12, -10, 10, 36, 48, -11, 4, 32, -7, -58, 13, -117, -1, 36, -8, 24, 40, 23, 2, 48, 26, 3, -12, 90, -17, -12, 27, -27, -17, -75, -34, 1, 36, 11, -13, 44, 35, 75, -4, 127, -7, 19, 44, 10, 11, 47, -4, 3, 16, -1, -10, 61, 2, -2, 16, 4, -28, 48, 10, 60, 2, 88, -13, -1, 8, -8, -3, 52, -15, -13, -2, 34, 8, 18, -47, 58, 1, 87, -28, 30, 17, 4, -13, 57, 2, 2, 47, 36, -13, 27, -17, 91, 3, 74, -20, 12, 16, 10, 1, 30, 1, -1, 26, 93, -5, 11, 4, 10, 4, 69, -15, 36, 23, 5, 11, 48, 16, 15, -25, 28, 3, -13, -10, -16, -25, 83, -8, 24, 44, 35, 28, 63, 15, 50, -36, 18, 4, -50, 8, -99, -3, 95, -23, 16, 41, 36, 47, 73, 38, 51, -26, 65, 1, -32, 27, -60, 10, 28, -11, 8, 65, 5, 71, 69, 80, 71, 28, 51, 1, 37, 62, 7, -1, 69, -125, -72, -8, -32, -114, 11, 127, -32, -46, 29, -118, -51, -61, 93, -96, 40, -34, -12, 77, -86, -101, -128, 3, -33, -74, -24, -78, -66, 18, -62, -97, 8, -115, -8, -43, -80, -128, -40, -18, -56, -22, 8, -99, -86, 16, -32, -60, -62, 63, -71, 1, -25, -56, -115, -8, -102, -49, 66, -68, -24, -20, -8, -33, -128, -12, -95, 72, -32, -29, -12, 49, -72, -83, -45, -96, -51, 83, -64, -40, 10, -9, -87, 8, -31, -85, 40, 72, -10, -50, 8, -107, -39, 2, -85, -103, -115, -90, -104, -80, 32, -48, -128, 74, -9, -6, -78, -44, -24, -1, -68, -55, -72, -16, -98, -83, 36, -5, -107, 21, -44, 11, -95, -109, -32, -1, -128, -81, -29, -71, -16, -75, -9, -110, -13, 35, -35, -74, 5, 112, -65, 74, -15, -91, -93, -101, -86, -31, -20, -42, -80, -75, -40, -29, -50, 7, -32, 29, -56, -32, -26, 14, -84, -11, 6, -27, -30, -56, -3, -55, -49, -112, 107, 44, -71, -30, 27, -4, -5, -61, 25, -31, -34, 9, -118, 40, -98, 4, 49, -3, -42, -61, -47, -33, -80, -26, -33, -57, 75, 5, -57, 20, -16, -49, 36, 8, -34, -63, 31, -50, -102, -38, 64, -117, 26, -81, -125, -38, -38, -56, -15, -42, -90, -117, -21, -16, 21, -120, -76, -30, -47, -4, -49, 11, -27, -55, -43, 14, -68, -38, 6, -57, -75, -128, 26, -56, 70, 23, -55, 39, 14, -14, 35, 55, -109, -5, -9, 61, -80, -32, -81, -38, -11, -72, 20, -44, -15, -42, 20, -43, 31, -40, -86, -46, -71, 36, 7, -128, 51, -52, -57, -81, -1, -47, -18, 11, 9, -67, 44, -58, -48, 46, 63, -4, 9, -115, -106, -19, -74, -36, -50, -74, -47, -44, -47, 33, -91, -35, 68, -44, -14, -66, -68, 61, -29, -112, 5, 36, -39, -115, -33, -96, -42, -78, 46, -80, -36, -119, -60, 8, -7, -115, -21, 12, 42, -106, 34, -75, -56, -88, -67, -2, -36, -97, -118, -45, -14, -93, -23, 14, -128, -42, 36, -1, -128, -80, -78, -128, -77, -61, -65, 9, 56, -119, -55, -49, -44, -12, -24, 32, -52, -107, -66, -29, -128, 18, -128, -66, -5, -75, 1, -9, -40, -43, -103, -128, 10, 47, -98, -93, 70, -128, -38, -36, 96, -83, -97, 9, -27, -7, 38, -104, -22, 38, -128, -93, -15, -101, -119, -20, 52, -15, -91, -33, -29, -128, -40, -126, -13, -35, -83, -10, 15, -44, -44, -90, 107, -35, -21, -77, -104, -27, -15, -11, -77, -18, -40, -58, -11, -72, -97, 35, 30, -68, -36, 31, 84, -98, 8, 6, -12, -49, 46, -40, -24, -56, -93, -84, -33, -23, -66, 5, -20, -9, 50, 21, 11, 12, -93, -128, 3, -104, -122, 38, -24, -81, -88, 4, -109, -55, 36, -10, -20, -51, 19, -84, 5, -81, -47, -34, 9, -80, 81, 9, -38, 20, 23, -3, -107, -88, -42, -50, 1, -27, -78, -8, 58, -60, 15, -2, -32, -40, -31, -6, 66, 31, -109, -47, -36, -29, -55, 19, -31, -6, -115, -23, -20, -63, -19, -19, -128, -1, -78, -86, -10, -15, -43, 22, -114, 119, -72, 14, -40, -45, 20, 8, -2, -49, -48, -20, 24, -110, -99, 25, -61, -98, -85, 1, -11, -88, -24, 18, -26, 16, -18, -20, -6, -44, -77, -38, 3, -81, -34, -23, 9, -81, -9, 32, -23, 78, 55, -75, -40, -128, -52, -22, -9, -56, -24, 57, -55, -60, 25, -26, -80, -47, -39, -112, -16, -25, -10, -40, 10, -128, -46, 16, -68, -62, 7, -10, -102, -51, -72, -81, -11, -48, -76, -12, -58, -128, 26, -81, -72, -106, 60, -74, -45, -128, -117, -118, 8, -2, -63, -40, 44, -47, 12, -48, -128, 3, 4, 87, 127, 27, -60, 19, -75, -120, -87, 127, -36, -60, -23, -66, -60, -39, 29, -128, -99, 50, 107, -62, 32, -68, -84, 50, -86, -99, -83, 43, 72, -1, 72, 127, -118, 1, -2, -72, 39, -35, -10, -25, -34, -49, 2, 38, -22, -128, -4, -1, 15, -2, -55, -74, 18, -76, -4, 16, -46, -71, -128, 7, -84, -84, -25, 52, -72, -10, -46, -72, 11, -24, -2, -19, 13, -77, -87, 34, -109, -128, -30, -7, -32, -40, -24, -47, 11, -60, -43, 30, -26, 21, -106, -1, -128, -60, 25, -40, -110, -122, 27, -81, -43, -113, -29, -8, 14, -40, -128, 24, -24, -46, 61, -26, -25, -51, -57, -90, -5, -86, -4, 44, -6, -74, -57, -15, -8, -46, 87, -20, -31, -36, -1, -80, -2, -128, -9, -68, 6, -99, -72, -32, -31, -58, -12, -58, -102, 11, -70, -93, 30, 6, 3, -98, -24, -88, -45, -56, -2, -109, -21, -60, -43, -31, -128, -62, -3, -101, -102, -8, -128, 74, 11, 15, 33, -128, -11, 74, -63, -15, -83, -16, 55, -4, -63, -50, 15, -128, -128, -13, 6, -50, 45, -71, -21, 8, -42, -40, -40, -103, -65, 74, 52, -106, -90, -14, -99, -71, 12, -31, -9, 25, 6, -66, -49, -38, -27, -10, -13, 34, -72, -77, 11, -111, -22, 70, -128, -67, -16, -97, 14, -44, -57, -19, -55, -86, -81, 24, -64, -90, 45, -31, -76, -96, -70, -13, 11, -39, -31, 19, 8, -96, -32, 13, -95, 14, 43, -11, -2, -12, -65, -12, 3, -128, -76, -38, -62, -45, 1, 74, 23, -31, -22, -78, -67, -5, -106, -108, -8, -51, -4, 86, -45, -33, -87, -38, -22, -48, 4, 8, -83, -27, -85, -13, -4, -88, 8, -51, -24, -91, -64, 40, 14, -68, 6, 39, -4, -75, -78, -100, -1, -57, -64, 7, 40, -20, 9, 15, -13, -72, -2, -18, -31, -6, -100, -52, 8, -10, -97, 8, -18, -88, -110, -77, -103, -63, 7, -5, -26, -48, -86, -128, -19, -31, -55, -8, -25, -21, -118, -31, -114, -40, 16, -5, -43, -65, 103, -102, 8, -44, -87, -18, 8, -76, 72, 22, -34, -48, 11, -10, -64, -128, -106, -3, -2, -26, -81, -1, -81, -29, 127, 20, -103, -45, 46, -24, -2, 20, -80, -99, 78, -123, -111, -44, -47, -68, -93, 72, 29, -66, 6, 23, -52, -56, -68, -81, -44, -62, -128, -107, -99, 24, -13, 36, 14, -50, -32, 19, -45, -56, -97, -109, -128, -83, -34, -1, -32, -5, -66, 14, 81, -64, 20, -40, -26, -30, 87, -55, -40, -31, -128, 39, -43, -128, -74, -22, -9, -43, -30, 65, -102, -10, 71, -123, 61, -67, -26, -26, 21, -62, -76, -10, 61, -56, 48, -70, -62, -2, -111, 11, -12, -114, -56, -3, 10, -50, -19, -56, 58, -80, -35, -76, -80, -64, 51, 19, -32, -71, -60, 14, 5, -104, -81, -22, -49, -62, 7, 4, -58, -49, -51, -128, -29, 8, -68, -78, -78, -78, -39, -72, -75, -31, -81, -75, 20, 30, -23, -43, -21, -58, -12, -2, -48, -47, -48, -40, -21, -86, -50, -68, -50, -47, 81, -1, -58, -109, -61, -45, -35, -29, -46, -21, 68, -50, 25, 20, -57, -33, -128, -128, 45, -128, -124, 29, -81, 19, -72, 3, -31, -84, 56, 45, -78, 4, -96, -107, -8, -18, -78, -16, -14, 19, 4, 15, -71, -128, 35, -56, -33, -30, -72, -71, 62, -114, -67, -19, -63, -113, -74, 63, 121, -14, 2, 67, -16, 2, -62, -4, -78, -56, -49, -29, -103, -33, -62, 7, 108, 10, 56, 27, -96, -128, -72, -102, -34, -84, 75, -15, -6, -3, -126, -15, -47, -35, 25, -3, -58, -77, -50, -103, -22, -80, -98, 42, 2, -35, -75, 55, -104, -72, -77, -21, -4, -91, -48, -63, -71, -24, -2, 1, -63, -26, -71, -27, -11, 20, 18, -60, 26, -58, -111, -128, 25, -42, -62, -10, -110, -108, -47, -97, -40, -128, -66, 64, -118, -93, -64, -81, -48, -16, 19, -1, -128, -23, -128, -36, 10, -121, 20, 15, -40, -35, -39, -26, -36, -25, 127, -4, -93, -64, -62, -1, 8, -96, -4, 42, -16, -13, -16, -115, -22, -66, 49, -76, -29, -128, -36, -52, 56, -128, 30, 13, -118, -124, -86, -128, -32, -65, 50, -61, -122, -91, -71, 20, 120, -97, 34, -55, -68, -24, -57, -104, 7, -76, -39, -29, 50, -18, -124, 51, 15, -76, -46, 4, -43, -32, -128, -42, -48, 1, -103, -32, 47, -102, 18, -125, -21, -58, -45, -8, -22, -21, -7, -128, -128, -75, -49, 10, -128, -56, -56, -29, -34, -31, -47, 16, -20, -111, 12, -40, 58, -25, 10, 1, -103, -88, -128, -36, -4, -85, 27, -6, -86, -83, -16, -40, 11, -128, -64, 8, -117, -121, -52, -5, -35, -67, 38, -67, -90, -113, -125, -31, -22, -91, 15, -56, -48, -84, 4, 15, -39, -126, -40, -43, -52, 44, -67, -50, 62, -128, 55, 52, -1, -94, -74, -25, -25, -103, 50, -13, -24, -74, -43, -75, -18, 19, -32, -13, -34, -67, -51, -30, 81, -60, -2, -33, -71, 112, -85, -90, -18, -45, 56, 74, 14, 86, -40, 71, -72, -67, 47, 40, -86, -50, -22, -109, -47, -128, -70, -12, -40, 122, -120, -44, -83, -31, -1, -15, 41, -32, 80, 8, 37, -41, 23, 34, -22, -20, 106, 24, -39, 3, -15, -1, 10, -67, -8, 12, 20, -32, 20, 19, -47, -9, 80, 98, -74, -13, -48, 3, 15, -70, -68, -5, 47, -66, 27, 9, -63, 3, 23, 49, -19, 3, -1, -12, 23, -128, -22, -15, 49, -20, 4, 28, -14, -8, -48, -12, -19, -28, 38, -30, -4, -80, 16, -18, 48, 8, 20, -4, -3, -4, -41, 1, -20, 2, 28, 4, 41, -28, 28, -13, 30, -18, -6, -9, 23, -1, -62, 9, -9, -12, 10, -20, 20, -51, 56, -1, 22, -23, 1, -1, 28, -24, -12, -1, -9, -9, -19, 3, 22, 10, -1, 19, 33, -2, 2, -3, 8, 20, 3, 8, -8, -1, 18, -9, 23, -69, -18, -8, 27, 19, -9, 24, 5, 4, 51, -5, -27, 1, 1, 10, 32, -39, 14, -2, 33, -15, -2, 13, -27, -6, 81, 22, 16, 9, -27, 2, 34, -48, 2, 4, -6, -19, 8, -34, 9, 4, -16, -2, 64, -3, 56, -5, 19, -38, 45, 16, -1, -34, -8, 32, 9, -1, -16, 24, 35, -9, 127, -15, 9, -35, -24, 2, 27, -27, 22, 14, 1, -4, -65, -1, 8, 2, 124, 4, -2, 46, 20, -1, 47, -16, 10, 19, 30, 1, -55, -16, -23, 6, 113, -8, 18, 47, -4, -3, 57, 1, 19, 1, 74, -6, -45, 1, -19, -8, 56, -18, 28, 79, 6, -1, 20, 1, -9, -8, 1, 5, -12, 13, -13, -2, 41, -1, -28, -18, -115, 10, 10, 1, -18, 3, -6, 2, 47, 9, 68, -12, -27, -20, 23, -37, -46, -9, 33, -9, -18, 2, 23, -4, 46, 13, 118, -18, 65, -20, 9, -28, -54, -6, 10, -3, -9, -2, 19, 5, 8, 2, 62, 15, 70, -16, 18, -8, -66, -20, 2, -54, -3, -9, 20, -3, -5, 9, 24, -1, 64, 1, 24, -19, 1, -12, -20, -16, -3, -1, 34, -4, -5, -8, -8, -6, 97, -1, 1, 23, -5, -22, 33, -12, 20, -6, 23, 2, -20, -1, -2, 5, 74, -24, 18, 55, 10, 6, 54, -1, 13, -2, 18, 22, -30, -14, -10, 14, 82, -20, 30, 82, -3, -6, 38, 15, 9, 5, -6, -8, -55, 19, -9, 6, 49, -20, -13, -33, -6, 16, 46, -2, 4, -19, -30, 27, 14, -23, 55, -12, -14, -9, 15, 5, 6, 22, 35, -9, -3, 4, -44, -15, 30, -4, -30, -6, 48, -19, 5, 28, -18, 3, 55, 5, -23, 15, -9, 1, 48, 10, -8, 2, 44, -1, 20, 62, -20, -19, 13, -2, -19, 1, 49, -2, 13, 24, 2, -1, 1, -10, 37, 64, 28, 2, -32, 9, -2, 2, -2, 24, 44, 13, 20, -2, -5, 2, 15, 4, 52, -24, 32, -41, 41, -20, -47, 1, 32, -34, 49, -2, 67, -15, 9, 1, 5, -27, 46, -12, 8, 10, -23, 1, 14, -14, 10, -28, 115, 10, 23, -12, 5, -20, 66, -3, 41, 19, 127, -6, -63, -10, -3, 5, 83, 10, 10, -3, -18, -4, 57, 13, 20, -23, 35, 27, -1, -1, -44, -12, 8, 1, 4, -39, 9, -5, 74, -12, -2, 16, 4, -22, 10, -23, -44, -28, 35, -1, 8, -20, -13, -2, 81, -33, -22, -2, -24, -15, 1, -24, -28, 18, 20, -16, 15, 3, 16, 4, 47, -19, -9, -15, -55, 5, 27, 33, -8, -2, -39, -12, 14, 34, 28, 15, -24, -9, 15, 2, -35, 15, -12, 49, 34, -8, -66, -10, 35, -65, -28, 8, -78, -13, 32, -1, 23, -1, -30, 41, 41, -16, 23, 12, 16, -64, 4, 3, -41, -30, 37, 3, -2, -12, 63, 67, 23, 1, 110, -28, 8, -15, 20, -9, 32, 1, 46, -2, 14, -18, -38, -27, 28, 4, 77, -30, 1, 37, -12, 12, 18, 3, -18, -19, 78, 41, 22, 13, -19, -16, 39, -1, 15, 16, 115, -4, 28, 13, -30, -20, 34, 5, 6, -18, 2, -28, 24, -2, -32, 19, 49, -1, 35, 14, -30, -5, 47, 10, 39, -24, -39, -14, 38, -14, -20, 5, 86, -9, -20, -33, -12, 1, 24, 10, 22, -15, -18, -2, 20, -15, 27, -28, 63, -15, -49, -16, -20, 19, -1, -4, 28, 91, -1, -5, -48, 6, 1, -77, -8, -5, -67, 18, -14, -3, -30, -6, 45, 115, 32, 19, -28, 1, 34, -64, 13, -4, -57, 3, 18, -6, -6, -20, 20, 63, 24, 18, 66, -8, 1, -38, 16, -8, 28, 14, 44, 6, 49, 34, -92, -75, 4, 9, 49, 9, -2, 33, -62, 19, 55, 34, -5, -1, 28, 28, -5, 37, 127, -8, 83, -32, -15, 41, -69, 8, 73, 14, -1, 14, -2, -5, -8, 41, 97, -5, 79, 4, 8, 9, -4, -16, 37, 6, -27, -19, -18, 5, -9, 32, -10, 1, 110, -34, 16, 54, 32, 1, 6, -5, -28, 10, -5, -16, 10, -3, -28, -15, 88, -28, 22, 20, -1, -6, -18, 9, -24, -9, 34, 12, 20, 65, -68, -10, -10, -28, 15, -47, 5, -8, -47, 1, -44, 19, 38, -27, 30, 120, 14, -19, -41, -24, 35, -32, 20, -10, -27, -4, -3, -13, 74, 14, 49, 99, 2, -12, -102, -14, 1, -1, 13, 4, 44, -12, 16, 4, -24, 32, 20, 32, 34, -2, 1, -10, -3, 10, 13, 10, 92, 22, 39, -23, 3, 10, -20, 41, 81, -13, 87, 1, 24, 90, 46, 2, 91, 16, 8, 3, 19, 1, -20, 48, -4, -9, 117, -22, 13, 35, 1, 4, 88, 19, -12, 16, -35, -3, 9, 83, -32, -9, 86, -9, -22, 69, -65, 14, 44, -8, 5, 2, -74, -3, 9, 90, -57, -19, 20, -10, 1, 82, -24, -1, 27, 13, -16, -6, -93, 24, 32, 113, -38, -20, -46, -28, -6, 16, 16, -13, 38, 41, -27, 20, -91, 1, 28, 127, -64, -3, -49, -14, 24, 20, -5, 3, 48, 73, -56, 2, 41, 5, 63, 52, -19, 4, -104, -14, 22, 8, 27, -9, 51, 1, -45, -15, 22, -14, 127, 62, 8, -5, -113, -1, 6, -20, -5, -6, 93, -34, 8, 8, -18, -41, -8, -41, 127, -34, 108, -5, 24, 49, 19, 5, 124, -38, 9, 12, -45, -3, -35, 15, 70, -12, 127, -3, 20, 28, 9, 8, 101, -20, 10, -1, -3, -22, -55, 67, -63, -9, 127, -14, 24, 18, 18, 9, 70, 10, -8, 13, 1, -23, -1, 63, -83, -13, 39, -9, 37, -15, -1, -6, 73, -2, -2, -13, -88, -1, 4, 97, -57, -3, -52, 9, -16, 13, 22, 18, 103, 23, -30, -2, -128, 20, -16, 127, -33, -9, -67, -33, 3, -30, 12, 2, 77, 67, -48, 19, -128, 18, -57, 127, -55, 6, -75, -6, 5, -39, 6, -22, 108, 82, -34, -1, -108, 12, 46, -13, -32, 2, -68, -6, -3, -14, -52, -22, 56, -37, -24, -2, 46, -4, 35, -86, 83, -28, 74, -33, 14, -22, -33, -5, 56, -51, 5, -2, 20, -18, -15, -34, 62, 1, 75, -35, 18, 3, -20, -3, 54, -20, 12, 20, -19, -16, -34, -24, -32, 9, 105, -28, 30, -1, 8, -9, 23, -6, -9, 16, 37, -8, -27, -4, -63, -1, 51, -16, 22, -28, 2, -16, 38, 4, -3, -10, 14, -18, -3, 2, -47, -4, -10, -14, 2, -22, 39, 2, 88, 19, 5, 2, -33, -28, -18, -6, -35, 2, -34, -27, 12, -27, 32, -1, 63, 16, -16, 8, -86, 13, -80, 103, -27, -1, -87, -9, 20, 79, 1, -20, 115, 44, -48, 5, -128, -20, -41, 74, -49, -1, -22, -16, 13, -28, -90, -10, 23, -24, -28, 16, 5, -19, 48, -13, 127, -33, 69, -4, 4, -20, -10, -2, 28, -28, -34, 8, 8, 13, 16, -39, 127, 6, 127, -9, 13, -18, -5, -32, 39, -6, -16, -3, -48, -13, -8, -49, 10, -5, 127, -3, 23, -22, -114, -19, 18, 2, -20, -14, -8, 8, -33, -28, -46, -15, 110, -19, 24, -38, -128, -23, 4, -8, -30, 10, -30, -1, 13, -22, -47, 5, 65, -4, 4, -63, -20, -37, 6, -27, -2, -12, -52, -12, 18, -45, 13, -20, 87, -6, 28, -56, 10, -41, 9, -28, -13, 20, -117, 13, -49, -68, -12, -27, 38, -10, 15, -2, 15, -20, 48, -39, -74, 13, -128, -28, -49, -51, -37, -5, 82, -12, -2, -13, -41, -13, 52, -5, -5, 12, 4, -10, 30, -56, 105, -1, 66, 5, 1, -22, -32, -27, 23, 3, -13, -3, -34, -9, 44, 9, 124, -18, 105, -1, 10, -20, -13, 6, 6, -37, -4, 32, -54, -9, 19, -20, 108, -18, 127, -30, -18, -15, -1, 1, -1, -41, -28, -12, -102, -15, -45, -46, -56, -18, 108, 1, 27, -22, -67, 1, -9, -18, -27, 10, -57, -20, -9, -69, -54, -2, 52, -6, 38, -57, -93, -52, -14, -27, -46, -4, -19, -2, 12, -68, 47, -9, 93, -27, 39, -90, -128, 20, -32, -28, -28, -1, 71, -19, -2, -70, -1, -5, 73, -3, 33, 8, 27, -51, -2, -67, -51, -45, -9, -19, -45, -102, -41, -9, 127, 9, 9, 100, -30, 18, 55, 56, 28, 8, 11, 15, -56, 45, 83, 2, 62, 5, 15, 115, -19, 10, 57, 41, -26, 7, 9, 34, -60, 41, 32, 21, 104, 11, 2, 97, 23, 6, 62, 37, -42, -1, 11, -4, 94, 46, 5, 28, 9, 4, 18, 69, 35, 23, -24, 20, -30, 26, 4, 9, 104, 32, -20, 31, 1, 17, 9, 30, -10, 9, -25, 11, -11, 33, 1, 15, 89, 5, 6, 8, -10, 9, 17, -34, -6, 1, -46, 20, -14, 8, -14, 5, 81, 8, 9, 20, -3, 10, 26, -1, -18, 21, 27, 7, 18, -14, 26, 20, 18, 1, 18, 25, 34, 1, 20, 28, -6, -1, 2, 13, 5, -9, 56, 26, -10, -2, 15, 20, 6, 19, 10, 80, -28, 35, 65, 48, 23, 25, -17, -9, -46, 14, 89, 2, 109, 2, 17, 88, -86, 10, 79, 43, -24, -13, 3, 2, -51, 15, 127, 1, 127, 1, 9, 81, -30, 17, 70, 19, -25, 13, 15, 4, 35, -4, -11, -1, 123, -3, 3, 61, -46, 4, -23, 19, -24, -3, -1, 11, 79, 32, -34, 18, -29, 3, 17, 56, -41, 5, -53, -17, -17, 28, 14, -2, 54, 51, -27, 8, -35, 2, 21, 5, -54, 13, -46, -9, -3, -5, 13, -8, 60, -13, -8, 19, -35, 15, 20, 10, -7, 14, -5, -9, -1, 13, 17, 27, 8, 4, 31, 11, -15, 26, 7, 6, -3, 19, 46, 5, -18, 10, 40, 21, 10, -1, 19, 1, 18, -4, 27, 69, 32, -20, 54, 11, 37, 11, -15, -7, -54, 3, 123, -6, 127, -6, 19, 81, 14, -9, 80, 37, -1, 6, 44, -7, -58, 53, 115, 9, 125, 13, 7, 89, 87, -7, 42, 35, 9, -3, 54, -19, -41, 47, -64, 25, 127, 5, 31, 79, 23, -17, -11, 47, -28, -2, 41, -4, 19, 41, -73, 19, 47, 2, 25, 30, 7, 18, 3, 43, -33, -14, 4, 6, 41, 37, -30, 18, -14, 9, 31, 21, 6, 10, -8, 29, -10, -8, -8, -9, 78, 34, 2, 19, -42, 8, 17, 14, 4, 14, -11, 33, 5, -15, -14, 1, 19, 10, 14, 8, -30, 15, 5, -41, 15, 32, 14, 29, 4, 9, 2, 4, 8, -9, 21, 14, -1, 17, -10, -1, 72, 2, 17, 1, 18, 10, 40, -43, 4, -15, 123, 4, 127, -3, 9, 52, 46, 5, 30, 25, 18, 29, 92, 7, -47, 37, 127, -10, 127, -5, 15, 43, 28, 11, 41, 26, 1, 11, 45, -1, -55, 5, -70, -5, 127, -3, 9, 105, -3, 41, 3, 31, -9, -4, 32, 18, 37, 51, -79, -1, 32, 2, 19, 113, 18, -1, -10, 35, -9, 3, 46, 1, 17, 56, -46, 10, -24, 7, 20, 94, 18, 1, -44, 42, -10, -14, 43, -25, 83, 49, -1, -8, -44, 26, 25, -7, 15, 15, -27, 13, -2, -14, -1, -1, 36, 41, 6, 14, -24, 13, 30, -20, 8, 11, 15, 10, -8, 32, -52, 13, 31, 36, 20, 3, -4, 13, -29, 15, 71, 6, 40, -24, 8, 28, -1, -28, 8, -25, 111, 9, 127, 9, -29, 72, 98, -2, 29, -3, 15, 1, 49, -20, -17, -13, 108, 8, 127, -6, 19, 123, 73, 31, 47, -8, 29, 4, 34, -26, -21, 19, 3, -3, 127, 10, 25, 64, 19, 19, 7, 7, 3, 1, 25, 3, -6, -24, -67, -2, 89, -4, 14, 52, -2, 13, 5, 32, -5, 7, 42, 2, 43, 33, -55, 7, 1, 17, 25, 62, 98, 11, -41, 31, -1, 15, 48, -14, 69, 77, -32, 9, -53, 7, 27, 28, 17, 8, -7, 40, 8, 6, 26, -19, 18, 43, 13, 23, -26, 1, 20, -33, 15, 5, 3, 23, -13, -14, 5, 6, 27, 111, 3, 5, -1, 10, -25, -2, 13, 11, 73, -18, 5, -11, 15, -37, 61, -54, 117, 14, 127, 1, -13, 21, 1, 15, 80, -17, 18, 10, 9, -23, 60, -43, 127, 6, 127, 1, -20, 51, -65, 26, 64, -47, 30, 8, -18, -4, 40, 8, 48, 8, 127, 19, 15, -1, -31, 17, -17, -15, 14, 14, -4, 2, 18, 29, -48, 17, 117, -7, 27, -4, -8, 20, -43, 3, 2, 9, -27, -21, 14, -5, -48, 4, 21, 20, 21, -42, 98, 27, -45, 5, -11, -6, -20, -3, 15, -51, -48, -7, -33, 6, 27, -27, 3, 4, -35, 44, 2, 8, -55, -2, -14, -56, -10, -7, -21, 8, 11, -24, 9, 9, -15, 2, 1, 9, 3, 27, -1, -13, 4, -2, 14, 1, -11, 14, -3, 8, 49, 1, 8, 24, 8, -36, 5, -53, 112, 8, 71, 14, -13, 19, 31, 29, 30, -25, 1, -15, 9, -9, 123, -69, 127, 9, 109, -6, -18, 36, 25, 33, 20, -51, 10, -10, 2, -5, 71, -43, 74, 8, 106, 5, 11, -21, 48, 17, -58, -23, -1, -1, 6, 1, 2, -11, -19, 4, 54, 9, 10, -13, 70, 6, -47, -31, 11, -18, 7, -6, 4, 13, -30, 9, 55, 25, 17, -24, 47, 5, -84, -14, 20, 14, 17, -2, -5, -25, -45, 19, 4, 1, 18, -24, 9, 21, -47, -24, 9, -10, 74, 13, -5, -57, -8, 15, 9, -1, 15, -29, 29, 23, -26, -2, 26, 14, 109, 26, -10, 18, 9, 17, 20, -8, -7, -48, 45, -11, 4, -11, -7, 2, 14, -5, -20, -14, 116, -2, 77, 6, 2, -19, 23, -18, 4, -30, 6, 7, 23, 3, 29, -43, 122, -3, 67, -1, 19, 6, 1, 3, -17, -45, 25, -5, 23, -6, 103, -41, 11, -2, 117, 13, 29, 15, 28, 4, -46, -23, 3, 3, 17, -4, 43, -35, 3, 2, 57, 10, 19, 13, 80, -3, -69, -18, 1, -3, 70, -1, 5, -36, -27, 5, 31, 11, 11, -6, 8, 8, -63, -29, 2, 8, 91, 5, 40, -60, -8, 13, -44, 9, 17, -11, 21, 5, -44, -44, 30, 7, 54, 4, 13, -41, 20, 11, 8, 20, 15, -4, 24, 23, -34, -9, 37, 8, 29, 3, -44, 1, 19, 7, 44, -3, 5, -29, 9, -1, -35, 1, -8, 24, 10, 11, -32, -35, 80, 24, 63, 9, 11, 21, -2, -8, -26, 11, -9, 24, 48, -13, -11, -42, 62, -6, 77, 24, -13, 15, -13, -1, -36, -21, 1, -3, 32, -4, 1, -44, 18, 23, 69, 8, -24, 34, -26, -13, -46, 1, -1, 2, 58, 11, -14, -21, 10, 3, 42, -4, -24, 61, -4, -14, -62, 27, -6, -8, 77, 18, -5, -33, -31, 3, 14, 7, 9, 20, -9, -3, -96, -3, 8, 1, 72, 29, 86, -58, -30, 13, -44, 2, 10, 37, 7, 5, -46, -53, 41, 8, 117, 27, 97, -91, 24, 8, -19, 10, 26, 15, 15, 13, -53, -61, 62, -4, 106, 18, 17, -20, 44, 7, 29, 24, 8, -14, 5, 17, -3, -21, 2, -3, 18, -10, 9, 20, 65, 9, 37, 2, 9, 17, -6, -1, -9, -23, -3, 8, 18, 26, -58, 17, 35, 19, 26, 13, 26, 29, -15, 9, -9, -1, -6, -2, 11, -1, 3, 54, 3, 18, 58, 11, -21, 2, -56, 34, -27, 15, 11, -7, 35, 26, -9, 28, -19, 28, 52, 20, -10, 53, -26, 41, -24, 29, -15, 1, 49, 29, -1, 44, -11, 5, 25, 14, -21, 8, -7, 19, -79, 40, -8, 7, 51, 26, 11, 14, -23, 14, -24, 6, 27, 10, 24, 23, -34, 27, 3, 7, 127, -4, 98, -24, 19, 31, -9, 30, 3, -55, 20, 6, -42, -18, 84, 1, 127, 19, 65, -32, 26, 13, 13, 23, -1, 6, -4, -1, -7, -6, 17, -18, 14, -1, -7, 10, 32, 29, 10, 21, -5, -5, -3, -3, -8, -8, 13, 3, 25, 6, 4, -20, -2, 18, -15, 13, 11, 21, 19, 13, 2, -13, 20, -13, 26, 13, -19, 18, -10, 8, -10, 20, -17, -1, 98, 31, -9, 23, 17, -21, 43, -1, -4, 15, -5, -1, 24, 14, -21, 48, 91, 69, 19, 6, 30, 2, 21, 24, -23, 71, -23, 4, 5, 24, -1, 36, 70, 67, -14, 67, -13, -1, 65, 18, -33, 96, -55, 18, -78, -2, 27, 49, 1, 41, -13, 61, 28, 19, 127, -1, 29, 83, 1, 6, -13, 4, 13, 8, 5, 24, 14, 92, 118, -15, 105, 19, 78, 54, 48, 8, -33, 14, 1, -1, 17, -1, -18, 17, 7, -6, 21, 25, 9, 5, 21, -1, -11, 21, 3, 5, 33, 25, -13, 10, 24, 4, 49, 21, 15, -18, 30, 14, -1, 18, 4, 14, 64, 18, -3, -2, 13, -15, 48, 14, -4, -18, 19, 5, -11, -3, 32, -7, 36, 17, -5, 10, 11, -21, 47, -3, -5, 2, 4, 11, -15, 13, 18, 36, 70, 43, -2, 9, 36, 21, -29, 13, -41, 13, -32, 10, 6, 15, -5, 96, 89, 127, 26, 37, 55, 15, 17, 23, -28, 57, -69, 17, -53, 15, 21, 107, 82, 53, 20, 62, 53, 19, -33, 4, -17, 86, -49, 3, -40, 24, 3, 6, 1, 118, 6, 90, 79, -34, 17, -3, 53, 106, 42, 7, -74, 17, 49, 47, -81, -90, -39, -53, -33, 85, 24, -88, 6, 112, 99, -49, 27, -114, 124, 125, -14, 44, -67, -39, -3, 87, 52, -56, -60, 24, 15, -39, 47, -29, -2, 4, -70, 24, 14, 26, 10, 36, -55, -28, 33, 28, -19, -17, -12, -8, 26, -33, 1, -113, 99, -49, -91, -36, 23, -27, -46, 2, -55, -40, -92, 18, 64, -114, -19, -96, 73, -92, 38, -99, 7, -17, -2, 34, -40, 53, -11, -15, 109, -65, 35, 1, -38, -48, -19, 122, 48, -16, -43, 28, -6, 48, -128, -36, 127, -107, 26, -122, 62, -57, 45, 106, -128, -9, 43, -81, 30, -33, -106, -26, 19, 36, 15, -86, -53, -36, 1, -46, 46, 26, -103, 62, 1, -81, -107, -61, 122, -51, -64, -16, -46, -81, 20, 30, 79, -49, -23, 80, 61, -39, 24, -8, 112, 3, 27, -102, -7, 14, 7, 105, 80, -102, 20, -30, -89, 24, -36, -20, -9, -20, 67, -24, 6, -128, 17, 103, 23, -14, -24, -14, -88, -29, -97, 34, 24, -65, 57, -38, 87, -73, -46, -120, -128, -22, 43, 29, -95, -87, -49, -30, 22, -79, 8, -43, 17, -111, -17, -126, -110, 9, -79, -60, -79, -49, -119, 51, 127, -94, -30, -20, 24, -90, -16, -51, 87, -56, 24, 19, -67, -119, -85, -24, 28, -105, -22, -39, 20, -27, -86, -33, -128, -9, -119, -27, -20, -7, -69, -51, 88, -49, 99, -24, -83, -30, -46, -44, -43, -44, -1, 36, -37, -67, -56, 40, 56, -81, 67, -60, -9, -89, -44, 127, 83, -8, -109, 127, 12, -52, 9, -49, -15, -8, 127, 45, -20, -9, -77, 92, 127, -99, -58, 16, 3, -67, -109, 2, 76, 38, 24, -39, -6, 44, 16, 46, -128, 11, -39, -22, -19, -61, -97, -109, 19, -8, 3, -15, 10, -60, 38, -8, 12, -64, -107, 65, -3, -29, -114, -122, 49, -8, 97, -73, -12, 16, -26, -15, -38, -62, -110, 7, -53, -14, -49, -69, 97, -49, 26, -87, -43, -24, 23, -30, 38, 6, -110, -87, -128, -97, -87, -109, 87, -14, 107, -10, -11, 24, 44, -70, 29, -128, -12, -60, -14, -5, -97, -46, 127, -125, -109, 1, -95, 19, -3, -28, 69, -67, -53, 32, -85, -81, -128, -2, -2, -72, 94, -35, 124, -88, -72, 55, 39, -92, -37, 29, -44, -43, 23, 16, 57, -105, 78, -3, -58, -128, -119, 46, 29, -49, -1, -19, 23, -39, 58, 8, 27, -128, 105, -76, 10, -52, -62, -48, 17, -89, -1, -22, -69, 4, 61, -30, 49, -81, 81, -121, 43, -121, 7, 47, -35, 11, 11, -9, -83, -112, -16, -83, 116, -20, 123, 15, 11, -121, -77, -40, 24, -102, -88, -86, -67, -92, 39, -19, 80, -40, -70, -15, -47, -64, -128, -43, 29, 22, -97, 14, -67, -90, -23, -87, 83, -11, 127, -109, -22, -79, -18, -49, -15, -38, -58, -9, 29, 49, -116, -39, 30, -38, -48, -111, -119, -12, 51, -80, -73, -23, -49, 43, -4, -57, -99, 18, -1, -90, 26, -35, 37, -73, -9, 103, 99, -20, -14, 30, 11, -38, 15, -40, 86, -27, 18, -120, -26, -81, -5, -49, 78, -56, -88, 1, 91, -89, 96, -85, 7, -3, 65, -128, 36, -14, -23, -53, -80, -46, -64, -20, -60, -95, 40, -15, 80, -102, 8, -86, -53, -43, -70, 43, 38, -69, -49, -58, -19, -51, 69, -80, 37, -38, 1, 39, -55, -28, -51, -32, 18, -64, 27, -62, -121, -123, 5, -48, 45, -3, 16, -43, 7, -64, -17, 69, 16, 11, -24, -57, -99, -37, -26, -128, -14, -36, 1, -26, -1, -92, -69, -48, -16, -83, -128, 49, -16, 12, -49, 5, 121, -16, 15, -52, -73, -1, -9, 83, -72, -29, -64, -5, -52, 5, -107, -11, -2, 29, 7, -39, 29, -23, -79, 43, 67, -128, -34, 115, -24, 5, 89, -128, -99, -51, -12, -7, -34, -62, -128, -46, 91, -38, -10, -15, -128, 27, 89, -19, 94, -39, -2, 5, 7, -83, -69, -11, 28, -95, -49, 49, -49, -48, 12, 20, 103, -48, 79, -55, 49, -30, 48, 9, 46, 30, -17, -48, -77, -70, 23, -58, 76, -15, 112, -36, 4, -77, 5, -33, -2, -103, -72, -72, -70, -24, -30, -106, 19, 5, 92, -11, 15, -112, 29, -49, -17, -7, -49, -30, 28, -106, -87, -70, 78, 17, -8, -65, -69, -76, -76, 6, -18, -79, -65, -49, -81, 5, -128, -33, 46, -85, -49, -52, -36, -90, -24, 14, 29, 15, -24, 86, -27, -49, 6, -115, -12, -86, -33, -86, -65, -2, -18, -110, 62, -86, -85, 17, -20, -80, 5, -35, -99, -39, 96, -128, 78, 20, -95, 27, 45, 1, -126, -40, 12, -78, 106, -76, -83, -60, 44, -12, -10, -64, -79, -38, -128, -30, -9, -19, -37, 1, -120, 20, 106, -125, 11, -55, 55, 48, -80, 15, -47, -83, -51, -81, 38, -128, -113, 4, 92, -62, 49, -37, -24, -49, -85, 23, -23, -94, -64, 62, -64, -11, 67, -72, 64, -116, 90, 27, -37, 2, 5, -12, -23, -69, -62, 22, -81, -86, 27, -40, 95, -29, 24, -122, -23, -73, -119, -78, -10, -24, -5, -57, -16, 39, -108, -80, 103, -9, 127, -69, 105, -24, -67, -35, -26, -76, -1, 55, 33, -24, -24, -87, 26, -40, -57, -107, -17, 36, -30, 22, 97, -85, -99, -11, -8, -27, -128, -114, -128, -72, 123, -6, -87, -3, -106, -1, 64, -53, 5, -55, -19, -12, -95, -24, 119, -106, 73, -116, 11, -19, -128, -7, 78, 17, -36, 5, -37, 8, -124, -34, -89, 17, 32, -61, 7, -49, -110, -3, -48, -73, -34, 17, 3, -38, -48, -2, 17, -88, 102, -16, -1, -88, -44, -51, -11, -81, -26, -10, -125, -38, -83, -43, 126, -128, 32, -85, -30, -19, -27, 12, 51, 10, -123, 7, -27, -34, 70, -128, 127, -85, 43, -4, 11, -5, -92, -3, 90, -72, -33, 58, -86, -14, -58, -39, 7, -90, 89, -85, 49, -11, -27, -45, -20, -10, -61, 90, -11, -11, -67, -65, 2, 39, -55, -83, 12, 17, -27, 119, 127, -79, -85, 23, 47, -52, -32, -16, -86, -3, 127, -39, 30, 24, -78, 39, 95, -36, 23, 55, 8, -77, -10, -67, -99, -61, 39, 7, 45, -67, -56, 7, 36, -58, -48, -49, -58, -15, -76, -128, -81, -126, 108, 8, 76, -19, -37, 47, 127, -127, -128, -35, -92, -27, -37, -36, 127, -30, 64, -48, -49, -110, -15, 9, 55, -128, -81, 49, -10, 40, 18, -128, 119, -65, 60, -48, 14, -46, -96, 33, 57, -17, -6, -24, -96, -60, -38, -110, 93, -93, 127, -67, 1, -9, 10, 77, 89, -128, -44, -29, -127, 2, 92, -40, 93, -38, 76, -22, 85, -77, -128, -49, -11, -126, -49, -9, -49, -47, 29, -105, -24, -23, -8, -96, 11, -24, -60, -7, 85, -64, 46, 3, 44, -128, -85, -128, -57, -33, 127, -125, -60, 22, 4, 45, 29, -3, -30, 32, -2, -67, -12, -93, 52, -49, 103, 46, -46, -52, -65, 1, 87, 9, -20, -29, -128, -49, -49, -1, -128, -72, 113, -35, -48, -45, -109, 81, 127, -97, -36, 27, -85, -127, -78, -80, -92, -24, 83, -112, -126, -87, -49, -1, 83, -128, -99, 23, -36, -49, -24, -61, 40, -33, 52, -55, -2, 2, 2, -8, 29, -24, -106, -69, -26, -60, -78, -78, 64, -110, 127, -62, -33, -128, -110, 16, -38, -80, -80, -95, -67, -51, 102, -69, 45, -61, 38, -32, -3, 10, -4, 89, 7, -110, -34, 5, -27, -79, -88, -128, 8, -102, 56, 4, -36, -15, 19, 18, 117, -108, -45, -61, -65, -89, -28, -38, 97, -9, 89, -93, -27, -27, -94, -23, 49, -32, -35, -43, 38, -128, 38, -125, 73, -33, 53, -45, -72, -76, 1, 47, 60, 33, 1, -23, -85, -80, -24, -62, -17, -40, 33, -17, -60, 24, 26, 19, -28, -9, -36, -10, -49, -35, -43, -61, -125, -90, 27, -67, -29, -37, -97, -24, 127, -102, -30, 48, -117, 18, -27, -113, 85, -36, 86, -20, 7, -89, -78, -27, 45, -73, -57, -128, 20, -67, 61, -65, 2, -89, 65, -79, -128, -16, -128, -3, -12, -102, -6, -1, 6, 6, 85, -55, 37, -127, 108, -76, 88, -35, 12, 10, 5, -78, -111, 36, -18, -96, 24, -128, 52, -87, -77, -34, 127, -43, -99, -12, -2, -53, -6, 106, 10, -57, 4, -70, 70, -69, 73, -89, 80, -89, 14, -6, -17, -23, -48, 127, -17, -93, 55, -47, 127, -88, 87, -40, 24, -90, -80, 34, 88, -91, -36, 34, 47, -55, 110, -19, -107, -16, 67, -28, 7, -4, -64, -49, 127, -103, -19, -15, -88, -127, 102, -91, -72, -34, -2, -34, 108, -60, -107, 10, 126, -61, -72, 7, -33, -117, 90, -1, -69, -57, 10, -18, 72, -96, -119, -61, 30, -9, -33, 30, -12, -67, -6, -103, -78, -96, -47, -48, 91, -92, -128, -11, 27, -20, -37, 6, -38, -109, 127, -52, -103, -5, -27, -14, -46, -128, -52, 89, 4, -99, 22, -35, -128, -67, 62, -15, 15, 29, 17, -1, 11, -8, -8, 24, 43, 13, 8, 43, 5, -11, -7, 11, 11, -3, -20, 1, -11, -36, -7, 18, 43, 8, 17, -27, 27, -5, 1, -17, 23, 13, 9, -11, 1, -25, -7, 18, 25, -8, 9, 5, 24, -7, 5, -2, 18, 27, 28, -7, 15, 1, 7, -1, -1, -11, 3, -9, 15, 3, 15, 1, 17, 67, 12, -7, -3, -12, 3, 30, 28, 1, -1, 9, 2, -24, 1, -12, 2, 20, -9, -11, 17, -8, 1, 24, 1, 1, -12, -2, -11, -28, 3, -8, 5, 23, 3, -8, 11, -27, 9, -20, 27, -2, 5, 15, -3, 2, 24, -20, -23, 13, 8, 5, 1, -11, 11, 3, -17, 15, 24, 9, 17, -11, 15, 12, 8, 7, -30, -11, 13, -13, 7, 20, -2, -2, -1, 30, 12, -20, -28, 3, 29, 13, 20, -17, -8, -2, 11, 12, 11, -18, 8, 59, 29, 1, -51, 1, 35, 1, -5, 1, -12, -11, 12, -23, 1, 11, 5, 24, 36, -21, -27, -13, 17, 2, 44, -13, 7, -11, 5, -34, -21, 3, 1, 5, 21, 2, 23, 1, 8, 2, -23, -11, 25, -38, -1, -18, -29, 9, 8, -1, -20, -3, -7, 1, 11, -24, -34, -13, 44, -9, -2, -9, 3, 2, 23, 1, 3, -12, -8, -24, 20, -44, -5, 2, 15, -11, -2, 3, -36, -2, 11, 7, 2, -8, -15, -18, 7, -13, 13, -11, 13, -25, 1, 11, -23, 7, -13, 5, 13, -5, 20, 7, -7, 36, -1, 34, 20, 12, 17, 3, 28, 12, -3, 61, -41, 11, -51, 2, 15, -3, 7, 28, 3, 18, 2, 15, 80, 2, -13, 43, -62, -12, -74, -24, 23, 12, -36, 28, 46, 2, 12, 3, 115, -1, -17, 48, 1, -5, -46, -12, 25, 38, 17, 24, 87, 9, 11, 3, 44, -15, -36, 49, 18, 1, -41, -11, 13, 9, 5, -7, 43, 17, 2, 2, 83, 18, -5, 42, 1, -2, 3, 5, 8, -61, 5, -1, 11, 11, 1, -1, 111, 13, 28, 48, -20, 9, 38, -13, 18, -9, -9, -8, 8, -3, 11, 1, 108, 3, 25, -29, -8, -12, 25, 1, 12, -21, 18, 1, 5, -18, -2, 21, 88, -12, 21, 1, 9, -3, -13, -11, 13, 21, -5, 20, 21, -5, 20, 5, -18, 5, -18, 30, -40, -13, -15, 1, 18, 8, -11, 3, 13, 5, 27, 21, -12, 5, -27, 85, -7, 1, -53, -9, 35, 36, 1, -9, 67, 18, 20, -25, -1, 9, -20, 78, 21, 1, -40, 9, 24, 93, 27, -15, 96, 36, 15, 1, 25, -21, -3, 78, 30, 2, -1, -7, 34, 64, -24, -13, 62, 18, -8, -13, 44, -1, -21, 65, 12, -9, 17, -18, 20, -36, -27, 1, 25, 18, 2, 9, 29, -12, 29, 80, -13, 5, 21, -11, 13, -11, 17, -12, -1, 11, -15, 12, -3, 1, 91, 41, 1, -2, 21, -13, 18, -9, 9, 3, -1, -12, -1, 5, -35, -23, 67, -82, -12, -8, -9, -8, 12, -23, 27, 13, 15, 9, 7, 15, -7, -1, 1, 11, -36, -1, -34, -11, 7, -21, 20, 3, 15, 24, -2, 2, -35, -20, -5, 18, -42, -5, -68, -13, 13, 5, -5, 11, 29, 9, 12, -9, 1, -3, -15, 15, 34, -11, -49, -2, 25, 65, 7, 5, 108, 11, 24, 1, 46, -2, -35, 124, 28, -1, 17, 2, 13, 72, -91, 13, 95, 20, -20, 3, 61, 5, -34, 98, -7, 2, 27, -35, 27, 13, -121, -15, 80, 1, -21, -7, 44, -1, -2, 99, -3, -23, 35, -17, 17, 68, -25, 9, 1, 20, -9, 18, 34, -3, 51, 53, -23, 1, 15, -5, 18, 28, 12, -20, -9, 5, -2, 9, 1, -1, 115, -65, -17, -18, -7, -21, 13, -18, 42, 1, -23, -8, -2, 5, 8, 2, 17, 8, -67, 1, -57, -15, 7, -43, 72, 3, -3, 3, 21, 18, -23, -8, 35, 29, -21, 8, -99, -7, 28, -30, 74, -12, -12, -3, 1, -7, -35, -5, -12, 11, 18, 3, -67, -7, 9, 9, 83, -5, 115, 17, 28, 8, -24, -1, -44, 30, 34, -7, 29, -11, 1, 12, 28, -20, 118, -8, 12, -1, -12, 2, -43, 86, 17, -11, 43, -25, 5, 53, -15, -29, 83, 7, -1, 12, 21, -2, -29, 127, -3, 1, 51, -30, 11, 95, 7, -9, 36, 23, -5, -8, 36, -7, 2, 64, -28, -1, 28, -36, 20, 42, 23, -21, 7, 17, -15, 7, 5, 3, 80, -5, -21, -12, -5, -20, 3, -8, -11, 18, -2, 2, 8, 15, 8, 18, 69, -2, -80, 13, -83, -11, 18, -23, 34, 9, 9, -1, 11, -13, 13, 17, 46, 5, -65, -5, -82, -13, 21, -34, 64, 7, -1, -13, 25, -7, -2, 2, -12, 8, 27, 2, -51, -8, 5, -12, -9, -9, 57, -11, 38, 2, -29, -5, -17, -9, 99, -1, 2, -1, 12, -25, -21, -8, 93, -20, 25, 1, -8, 1, -40, 29, 40, 5, 59, -24, 23, 41, 8, -12, 111, 7, -1, 3, -3, 1, -35, 127, 15, 3, 127, -24, 13, 80, 8, 8, 78, 27, -2, -2, 62, -28, -25, 98, -21, 1, 64, -8, 15, 64, 8, 2, 34, 17, -21, -13, -20, -21, 11, 67, -29, -7, 2, -9, -1, 8, -28, 1, 1, 20, 12, -7, -1, 7, 40, -1, -54, -2, -46, 1, 12, -1, 2, 9, 8, 7, 3, -15, -1, 21, 43, 12, -13, 11, -73, -18, 11, -43, 28, 2, -15, -3, -9, -17, -12, 7, 49, 25, 59, -11, -68, -9, 15, -2, 42, -18, 24, -15, 17, 3, -48, -5, -11, 17, 107, 3, 8, -8, 11, -5, 18, -13, 65, -9, 36, 8, -109, 2, -72, 28, 97, 1, 101, -13, 1, -12, 11, -5, 108, -8, 3, 3, -61, -2, -43, 83, 23, 11, 127, -15, 2, 18, 35, -21, 122, 24, -12, 15, 101, 8, -80, 34, -29, -9, 93, -5, -3, 17, 8, -9, 41, 24, -38, 2, -13, -23, -2, 95, -9, -9, 1, -9, -2, -20, 18, -8, 1, 3, 2, -25, 12, 40, -1, -3, -43, 1, -40, -7, 12, -44, 12, 1, 3, -1, 7, -7, -5, 27, 11, -9, -36, -2, -83, -2, 12, -74, -1, -3, -23, 18, -9, 3, -3, 3, 40, -25, 25, -5, -43, -8, 21, -44, -13, 2, 7, -1, 8, -5, 5, -8, 49, -20, 49, -8, -35, -20, 18, -42, -53, -3, 13, -29, 42, 15, -36, -8, -8, 24, 99, -7, 15, -3, 13, -7, 1, -11, 127, -3, 21, 1, -36, -5, -53, 119, 85, -2, 127, -5, 9, -13, 21, -3, 127, 12, -2, -1, -15, -2, -96, 127, -15, -11, 127, -15, 15, -12, 8, -3, 74, 13, -42, -13, -5, 5, -18, -51, -40, -7, 23, 7, 5, 11, 15, -2, 20, 8, -24, 8, -7, 36, -23, -7, -57, 8, -43, -13, -30, 5, -1, -9, -7, 8, -15, 12, 17, 7, -3, -9, -36, 2, -44, -2, 9, -12, 23, -25, -25, 18, 12, -11, 24, 11, -23, -15, -7, 3, -34, -1, 5, -25, 9, -21, 25, -1, 13, -9, -8, -13, 1, -67, 40, -13, -30, -23, 17, -74, -72, -11, 40, -44, 34, -17, -27, -11, 27, -43, 113, -11, -11, -17, 15, -43, 8, 5, 107, -29, 42, -7, -51, -27, 8, 5, 105, 1, 110, -11, 3, 28, 21, -3, 127, -25, 17, -7, -87, 30, -62, 69, 1, -11, 127, -24, 9, 34, 13, -7, 99, -3, -46, 8, -128, 9, -64, -7, -59, 7, 76, -15, 7, 12, -7, 11, 44, 25, 2, 8, 30, 18, -24, 3, -57, 8, -24, 5, 21, 12, 17, 24, 38, 28, -5, 9, 24, 11, -18, 9, -57, -7, -42, -9, 11, 9, -92, 15, 23, 30, -8, 20, 30, 17, -7, -12, -35, 2, -53, -23, 34, 13, -53, -15, 17, 21, -17, 27, 1, 20, 13, -25, 21, -8, -51, -1, 13, -49, -28, -29, 36, 11, -12, -2, -30, -12, 74, -35, 101, -3, -57, -15, 21, -54, 2, -13, 46, -36, 27, -7, -28, -17, 83, -95, 127, 2, 111, -12, 12, -41, 8, -15, 76, -51, -13, 1, -128, 17, -1, -101, 69, 2, 127, -18, 7, 30, 8, -5, 43, -73, -80, 11, -128, 13, -68, -92, -24, -7, 119, 8, 1, 8, -30, 23, 18, 25, -2, -12, 17, 17, 1, 36, -28, 15, -5, -8, -9, -5, 25, 8, 43, 30, 12, 11, 15, 13, -18, 34, -36, 3, -2, -8, -5, -3, 23, 18, 36, 36, 9, 2, 53, 21, -11, 49, -59, 1, -29, -13, 15, 17, -2, 13, 34, 29, -5, -8, 30, -5, -8, 40, -57, -3, -41, 1, 7, -51, -41, -27, 44, 41, -25, 18, 108, 1, 42, -1, 72, 11, -46, -11, 21, -115, -12, -53, 13, -2, -49, 15, -5, -38, 111, -72, 127, 2, 44, -5, 7, -98, 13, -23, 42, -65, -53, 25, -30, 11, 41, -128, 127, 1, 110, -7, 29, 23, -1, -40, 24, -93, -78, -13, -25, 2, -51, -123, -15, -1, 113, -30, -91, -77, 80, -128, 16, 127, -78, -40, -32, 34, -49, 98, 116, 13, -128, -12, -107, -73, -6, -107, -70, 61, -73, -99, -26, 53, -49, 77, 22, 69, 94, -100, -86, -14, -23, -92, 23, -12, -128, 14, 33, -126, -2, 22, -60, -47, 3, 127, -78, -26, 49, -86, 39, -44, -101, -92, 24, -43, -60, -5, -117, -24, 73, -43, -92, -1, 4, -40, -9, 31, -67, -46, 88, -16, -99, -8, -83, -46, 5, 59, -92, 34, -20, -40, -40, 18, -65, -68, 107, -33, -62, -35, -118, 26, 127, 127, -123, 27, -18, -121, 86, -4, -107, -128, 84, -128, -61, -1, -32, 32, 79, -126, -120, -100, -4, -51, -76, -53, 12, -20, -62, -53, 35, 32, -112, -70, 55, -74, 18, 4, 40, -86, -46, 20, 7, -33, 105, 27, -94, 14, 62, -99, 55, -16, -31, -9, 127, -53, 12, 12, -72, -90, 26, 79, -97, -14, 21, -35, -24, -128, -7, 6, 78, -13, 56, 49, -83, 17, 55, -120, 76, -46, -88, -45, 49, -52, 5, 15, -7, -39, 81, -5, -68, 17, 111, -109, 91, -62, 39, -17, 67, 1, 6, -37, -23, -60, -25, 60, -23, -72, 20, -128, -88, 32, 59, -28, -82, 57, -32, 62, -41, -38, 5, -31, -104, 12, 122, -113, -52, -3, 1, -90, 73, -30, -55, 39, 38, -128, 12, -49, -75, 13, -99, -94, -104, -55, -28, 16, 33, -61, -75, -33, -18, -128, 77, 46, -12, -9, -77, -119, 52, -13, 15, -119, 57, 67, -16, -14, 17, -31, 11, 86, 9, -114, 14, -57, -76, 23, -87, -56, 24, -111, -33, 62, 52, -128, 8, -4, -83, 43, 79, -14, -31, 9, -28, -76, 90, -88, 5, -15, -128, -87, 4, 127, -83, -38, 84, -14, -51, 14, 30, -51, -6, -119, -75, -37, 46, -105, -13, -67, -55, 31, 22, -22, -61, 31, 39, -82, 2, 67, 10, 6, 34, -104, 44, -60, -99, -12, 17, -32, -84, 40, 83, -45, 9, -69, -128, 94, -119, -57, -45, -108, -31, -32, 1, -76, -18, -11, -11, -83, 13, -112, -128, -2, 124, -16, -25, -68, -124, 11, 15, -15, -59, 13, -90, -72, 37, 2, -55, -34, -65, -97, 52, -116, -60, -52, 3, -53, -43, 26, 5, -116, -8, -107, -8, 7, -3, -70, -26, -128, -83, -48, 114, -72, -128, 102, -46, -96, 69, -88, -46, -41, -75, -128, 21, 97, -128, 97, 10, -124, -104, -25, -41, -101, -60, 105, -67, 53, 55, -17, 7, -101, -80, 18, 83, -44, -56, -8, 109, -60, -1, -1, 67, 40, -8, -123, -59, -86, -116, 14, 38, -97, -51, 7, 9, -51, 34, -1, -35, 41, -92, -39, 3, -99, -4, -28, -31, -81, -86, 12, 108, -128, 11, 72, -112, 45, -83, -52, 49, -73, -101, 8, -11, 38, -79, -22, 93, 6, 8, 34, -90, 114, 70, -121, 33, -30, -56, -72, -67, -4, -4, 22, -24, -69, 11, -62, -90, -17, -82, -128, -53, -120, -31, -49, -79, 127, -13, 47, -61, -118, -16, 27, 1, -7, -69, -87, -25, -70, -128, 26, 110, -9, -21, 15, 44, -114, -7, 121, -40, 8, -70, -32, -14, 5, -47, -77, 65, 13, -24, -26, -25, -59, 49, -33, -128, 81, 86, -121, 1, 26, -128, 1, -97, -33, -90, -77, 1, -111, -44, -17, 76, 61, 32, -33, -38, 102, -65, -74, 79, -44, -24, -3, -122, -70, 88, 49, -60, 33, 127, -81, 21, -65, -128, 76, -79, -119, -38, -84, 96, -126, -14, -32, -104, 25, -94, -122, 77, -128, -9, -3, 52, 68, -109, -27, 93, -84, 41, -49, -123, 47, 60, -72, -26, -62, -70, -31, -79, 82, -75, 13, -103, -68, -80, 20, -109, -126, -30, -86, 15, -84, -7, 21, 3, 100, -5, -72, 4, -30, -37, -104, 56, -1, 127, -14, 84, 76, -110, 4, 25, 8, -72, 37, -45, -72, -23, 15, 34, 26, 93, -128, -6, 49, -23, -67, 80, 88, -107, 13, -27, -104, -15, 78, 31, -46, 127, -121, -15, -21, -45, -18, 88, -25, 44, -4, 41, -40, -82, -31, 98, -1, 84, -113, -32, 55, -105, 4, 10, -59, -128, -21, 127, -35, 76, 11, -28, -46, 81, -119, 18, -116, 13, -45, -14, -27, -15, 6, 77, -107, -4, 23, 7, -18, 28, -61, 21, -114, -100, -72, 6, 93, -33, -2, -77, -65, -30, 32, -4, 76, -56, 13, 60, -14, -65, 14, 12, -68, -104, -6, -125, -120, 22, 31, -90, -70, 10, -128, -38, -21, -65, 11, 56, 4, 38, 13, -128, 2, 62, -15, -6, 13, -22, -26, -22, 21, -111, 75, 116, -112, -119, -114, -70, -59, 15, -103, -94, 5, 22, -27, 14, 30, -40, 123, 81, -91, 16, 18, 1, -92, 12, -114, -57, -91, 112, -41, 17, 37, 15, 39, -59, -75, 26, -25, 32, -61, 18, -12, -123, 1, 99, -40, -8, 127, 8, 61, 75, -107, 28, 49, 65, -18, 49, -70, -82, 8, 101, -82, 17, -127, -78, -12, 24, -82, -114, -82, -112, -70, 16, -87, -125, -70, 88, -48, -70, -38, 3, 60, 27, -10, -24, 14, -91, -67, -12, 70, -117, 32, -47, -91, 37, -25, -27, 1, -18, -37, -128, -7, -56, -124, -61, 23, -102, -44, -26, -57, 44, -81, -128, 17, 9, 57, 22, 1, -79, -37, 27, 43, 68, -30, -114, -128, -55, -32, -128, 112, 65, 59, 4, 31, -49, -128, 8, -124, -121, -2, 81, -21, -10, -76, -128, 60, 83, 26, -128, 12, 2, -128, -3, 4, -128, -46, 83, -87, -22, 110, 4, -34, 100, -44, -128, -28, 15, -77, 20, -28, -41, 25, 2, -62, 40, 17, -101, -46, 16, -26, -117, -69, -12, -5, -81, -49, -108, 45, 62, -109, -41, -108, -22, 28, 53, -21, -43, 83, -78, -30, -34, -27, -45, -6, -75, -128, -48, -41, -49, -10, -7, 118, -74, -47, -65, -82, -35, 69, -88, 41, 35, -32, -53, -79, -98, -65, 9, -62, -107, -1, -56, -25, 37, -46, -34, -46, -93, -104, 47, -93, -101, -55, 76, 78, -97, -69, 1, -53, 77, 17, -43, -8, -7, -34, -14, -127, -104, -2, -70, -86, -65, 18, -1, -10, 3, -72, -38, -15, -23, 11, 25, -45, -102, -12, 8, 6, -22, 26, -52, -69, -38, -25, -124, -75, -84, -78, 2, 30, -91, -32, 49, -22, -31, 6, -53, -76, -13, 6, -100, -9, -128, -122, -21, 107, -81, 15, 24, -101, -97, 35, -48, 1, -45, -32, -33, -13, -93, -70, 1, -93, -123, 1, 4, -102, -97, -2, -51, 20, -39, -78, -43, 48, -1, -98, 46, -35, -26, -43, -12, -60, -128, -33, 17, -44, -38, 57, -25, 104, -61, -98, 72, -128, -14, -40, 87, -13, -3, -2, -56, -52, -3, 82, -128, 21, -31, -15, 27, -27, -73, -9, -23, 103, -18, 1, -48, -57, -78, -32, 2, -4, -7, -62, 10, -70, 68, -44, -70, -52, -57, 16, 1, -16, 53, 43, -5, -25, 12, -1, -2, -80, 4, -88, -98, -32, -52, 59, -27, -97, 22, -12, -15, -33, -109, -33, -44, -91, -127, 49, 25, -60, -73, 22, -47, -49, -40, 14, -62, -13, -52, -10, -33, -40, -127, 13, -11, -84, -69, 6, 100, -56, -62, 43, -96, 3, -40, -7, -11, -41, -102, 1, 92, -77, -128, 2, -117, -38, -67, -15, -84, 62, -101, -51, -40, -37, -76, -24, 76, -45, -128, 23, 127, -74, 18, 81, -35, 127, 7, -37, -8, -39, 91, 22, 12, -70, -46, 24, 1, -13, 32, -77, -65, -94, -33, -109, 68, -41, -62, 28, -44, -92, -33, -5, -32, -33, -112, 15, -12, -61, -13, -128, 120, -79, 23, -27, -45, -12, -94, 97, 32, -59, 65, 83, -3, -107, -26, -57, -27, 1, 59, 37, -28, -96, -96, -4, -20, -98, 8, -37, 92, -128, -76, -88, 8, -77, 68, -4, -46, -31, -88, -55, 52, -104, 21, -31, -103, 127, 13, -22, 61, 17, -87, -38, -22, 9, -90, -92, 70, -59, 18, 14, -51, -74, -96, -109, 13, -40, -128, -47, -13, -73, -107, 44, 77, -122, -69, 8, -88, -93, -40, -46, -3, -128, 32, 20, -72, -99, -128, -60, -11, -73, 72, -1, -75, -128, -61, -92, 2, -69, 9, -35, 32, -69, -99, -103, -44, -11, 4, -60, -93, -107, -92, -119, -26, -128, -32, 9, 111, -128, 4, -82, -77, -53, -11, 52, 1, -48, 25, -39, -78, -53, -84, -73, -108, -88, -128, -108, 62, -40, -16, 33, -1, -65, -104, -35, 15, -84, 34, 5, -86, -93, -44, -22, -6, -75, 68, 34, -105, -2, -14, -92, 48, -30, -17, -91, -87, -37, -13, -26, -18, -13, -11, 12, -34, 44, -128, -62, -27, -97, -4, -49, -119, -70, -3, -32, 9, -37, -3, -56, -83, -7, -68, -76, 26, -67, 2, 10, -34, -118, -113, -20, -18, -7, -43, -20, -55, -12, 7, -23, 27, -2, 47, -5, -88, -24, -5, -24, -116, -76, -32, -34, -49, 46, -87, -69, -17, -55, -15, -75, -96, 88, -101, 21, -128, -94, 65, -121, -128, -62, -62, -45, 47, -15, -69, 2, -82, 53, -56, 23, -9, -83, -43, -63, -32, -64, 25, -99, -10, -51, 25, 38, 6, -58, -77, 99, 15, 17, -30, -59, 20, -43, -12, 4, 30, 49, -38, -72, 61, -127, 30, -52, 5, 1, -87, -93, 26, 17, -30, -66, -13, -57, 33, -75, -72, -37, -15, 24, 50, -30, -99, -80, -35, -43, -1, -47, -44, -13, -26, 46, 43, -127, -59, -94, -30, 1, -47, -89, 13, 22, -61, 16, 30, 13, -19, -16, 7, -76, -20, 1, 39, -63, -102, -16, 42, 10, -29, -76, 37, -96, -55, 40, 26, -116, -39, -64, -3, 29, -77, -29, -23, -44, 37, -35, 5, 69, -128, 77, -29, -80, -46, -13, 24, 58, -25, -57, -4, -17, -24, -128, -46, -35, -107, 14, -16, -128, -30, 57, -102, -38, -65, -78, -52, -119, 24, -48, -9, -81, -123, 15, -53, -16, -100, 48, -44, 22, -50, 73, -30, -51, -33, -116, -55, -65, 23, 57, -3, -128, 59, 26, -80, -2, -128, 15, -43, -39, -76, -10, 38, -40, -30, -96, -23, -79, -7, 25, 58, -51, -77, -26, -27, 10, -10, -9, 47, 13, -2, 3, 75, -32, 44, -4, 19, 51, -78, -7, -20, -82, -38, -44, -44, 10, 75, 39, -78, -77, -39, -3, 33, 89, -85, -10, -94, 24, -79, 29, -9, -92, -69, 17, -47, -77, -76, 86, -10, -64, -5, -39, 43, -1, -24, 16, -72, -12, -29, -57, 30, -128, -55, -2, -89, -32, -128, -7, 61, 12, 27, -35, -65, -13, -99, 12, -1, -38, -73, 101, -5, -19, 1, -27, 92, -109, 102, -22, -55, -128, -82, 40, -63, -102, -75, 66, -83, 52, -64, 86, -101, -23, -1, -128, -117, -86, -59, 94, -49, -128, -3, 27, 13, -30, -128, -128, -89, -128, 57, -27, -95, -44, -27, 1, -77, -79, -14, 44, -1, 1, -12, -58, 5, 35, -65, -53, -35, -73, -79, -29, -40, -65, 27, 17, 81, -18, -126, 2, 6, -50, 63, -85, -42, -35, -83, 63, 85, -106, -20, -64, -30, -22, -58, -30, -59, 86, 13, -42, -14, -51, -46, -35, -7, -109, -37, -44, -22, -27, 35, -81, -50, -49, -9, -19, 4, -82, -39, 25, 25, -18, 29, -16, -38, -48, -89, -128, -72, -63, 2, 22, -58, -52, -30, -22, 27, -93, 87, -17, -128, -29, 12, 2, -10, -104, -92, -52, -107, -109, -123, -57, -44, -39, -44, 2, -38, 102, -97, 37, 38, 23, 55, 16, -22, -5, -94, -56, 48, -72, -65, -1, 18, 38, -13, -30, 13, -86, 9, -29, 1, -23, -128, 61, -64, -80, 83, 23, -44, -23, -22, -10, 23, -85, 44, -51, 13, -128, -128, -29, -33, -128, -6, -37, 38, 53, -59, -22, 7, -16, 83, -38, 49, -44, -94, -5, 30, -128, -44, -80, 65, -16, 1, -42, 99, -59, -30, -27, -99, -58, 6, 7, 29, -97, 14, -46, -55, -1, -53, 2, -97, -18, -14, 19, 89, -120, 44, 44, -3, -12, -32, -15, -66, 30, -82, -24, 30, -75, 7, 58, -123, -51, -43, 13, -83, -47, -6, -37, -44, -29, -123, -20, 57, -17, -52, -128, -99, -22, 19, -30, -61, -35, -128, 24, -5, 89, -94, 57, -40, -4, 44, -79, 55, -81, -22, -15, 17, -58, -73, 6, -4, -56, 16, -115, -51, -75, 22, -64, 59, -94, -58, 24, -42, -128, -30, 8, -86, 4, -128, -44, 20, -35, -6, 59, 37, -128, -8, 3, -35, -113, -39, 9, 19, -50, -81, 52, 82, -30, 8, -65, 61, -92, -73, -87, 13, -105, 39, -4, -75, -17, -23, -47, -5, 35, 53, -96, 24, -128, 4, 77, 6, -53, -89, 66, -9, -51, 82, 4, -94, 29, 102, -85, 15, -80, -78, 1, 1, -23, 13, -39, -1, -102, -38, 44, 32, -101, -6, -51, -73, -75, -69, -35, -38, -48, -49, 17, -128, -58, -115, -79, 3, -44, -86, -25, 1, -32, -128, 6, 2, -128, -51, 1, -13, 15, -97, 69, -80, 5, 80, -100, 49, -46, -49, -44, -7, -79, 5, -33, -49, -19, -23, 6, -44, -118, -69, -86, 29, -113, -40, 10, 30, -42, -13, 24, -33, 16, 19, 38, 25, 30, 17, 40, -19, -126, 7, -66, 89, -24, -24, 3, 59, -25, -26, -44, 12, 47, -26, -30, -80, -33, -53, -32, -53, 22, 44, 33, -19, 29, -96, -82, 102, 57, 77, -58, 33, -32, -108, -49, -23, 8, -56, 16, 7, -58, 14, -3, -20, -71, -14, 30, -23, -37, -83, 77, 9, -116, -89, -56, 55, -128, -25, -51, -1, -12, 33, -8, -37, -73, -47, -33, -37, -47, -19, 15, -126, -10, -42, 59, -37, -48, 7, -81, -117, -94, -44, 32, -40, -38, -40, -18, -59, 50, 22, -13, -32, 44, -26, -100, -119, -78, -65, 27, 2, -89, 23, -22, 22, 3, -33, -58, 6, -49, 1, -117, -101, -128, 3, 35, 2, 4, -1, 56, -39, 66, -48, 16, -39, -27, -9, -79, -93, -52, 50, -61, -47, -93, -52, 39, 8, 57, -69, -55, 66, -80, 8, 44, -101, -32, -3, 102, -73, -77, -79, 35, 64, -16, -44, -18, -43, 24, 3, -98, 38, -83, 3, 19, -80, -128, -42, 65, -19, -58, -80, 27, -19, -52, 29, -35, 37, -43, -17, 24, -15, -39, 40, 25, -79, -78, 59, 38, -13, 3, 33, -29, -15, -85, -120, -26, -33, -35, -77, -20, -128, 13, 13, -18, -47, -50, -23, -81, -3, -128, -126, 1, 23, -72, -121, -53, -30, -46, -89, -20, -24, -25, -38, -115, -48, -71, -105, 2, -48, -113, -85, 27, 27, 8, -102, 25, -81, 13, 30, -116, -19, -76, -56, 61, -7, 10, 44, 69, 26, 46, -23, -80, -37, -72, 7, -1, 38, -76, -19, 22, 59, -37, 5, 5, -30, 83, -32, 44, -15, -128, 69, 55, 16, -30, 53, 40, -49, -128, -33, -33, 94, -50, 35, -32, -48, -38, 50, -9, 38, 9, -69, -30, 25, -128, 44, -63, -5, 30, -18, -14, 23, 15, -2, -50, -19, -119, -42, 27, -7, -7, -59, 47, -42, 2, -1, -17, 7, -4, -53, 42, -26, -57, -13, 49, 66, 30, -47, 5, -32, 16, -79, -57, -24, 7, 57, 80, 1, -30, -69, 69, 18, -106, -94, -15, 71, -79, -63, -4, 42, -44, -25, -1, 14, -53, -87, -16, 8, -49, -51, 63, -20, 27, -105, 39, -51, -24, -6, -50, -12, -72, -108, -25, -15, -37, 6, -30, 64, -51, -93, -19, -59, 24, 6, -19, 15, -29, 37, 40, 43, -80, 52, 14, 58, -44, -49, -35, -95, -37, 10, 66, -10, -89, 1, -23, -38, -86, 38, 64, -38, -2, -82, 76, -8, 66, -76, -98, -14, -33, -6, -95, -57, -30, 19, -53, -44, -79, -37, 1, 2, 19, 48, 39, 22, -55, -64, 4, 1, -33, -33, 27, -10, 8, -104, -27, -3, -42, 30, -55, 12, -12, -13, -30, 20, 23, -85, -43, -20, 18, -63, 3, -5, -78, 83, -27, -46, -82, -27, -13, -64, -89, -77, -53, -33, -55, -29, -17, 29, -20, 1, -128, -49, -105, -128, -44, 15, -105, -29, 47, -51, 61, -69, -80, 14, -6, -15, -13, -61, -53, -48, -19, -7, -50, -81, 76, 59, -16, -104, 35, 18, -69, -46, -85, 44, -89, 7, -43, 30, -89, 63, 89, 57, -42, -38, -16, 1, -23, -15, -1, -27, -77, -22, 24, -65, -128, 61, 58, 33, 57, -80, -25, 24, -18, 20, -116, -30, -107, -128, 101, 20, -32, 26, 30, -71, -48, -128, -71, 26, 63, -15, -38, 51, -89, 20, 4, -43, -44, -128, 79, -35, -18, -42, 43, -42, -58, 23, -27, -102, -78, -38, -20, -5, -42, -123, 7, -102, -16, 25, 50, -39, -109, 10, -18, 12, -59, -58, -66, 52, -128, -73, 48, -20, 33, -109, 7, -6, -3, 26, -104, 26, 14, -65, 5, -8, -17, -81, -17, 1, -30, -75, 63, -5, -81, -79, -27, -3, -65, -35, 23, -39, -32, 19, -38, -6, -30, -58, 30, -5, -58, -48, -108, -30, -86, -39, 64, -69, -101, -18, -3, -73, 50, -19, 101, -46, -26, -78, -61, -39, -10, -73, -51, 10, -106, 86, -65, -61, 1, -30, -27, -8, -30, -4, -64, -27, -17, 9, -44, -55, -43, -30, -72, 101, -39, -85, 8, 50, 40, -40, -32, -120, -19, -6, 33, -47, -15, -30, 30, -69, -18, 15, -3, 4, -128, -65, -1, -128, -42, -18, 35, -57, -85, -96, 24, -128, -35, -61, -6, -13, -76, -27, -47, -89, -101, -18, 9, 38, 24, -98, -44, 12, 37, -71, -59, 63, -37, -73, -30, 5, -128, -53, -23, -18, 16, -128, -50, 27, 33, -57, -61, -63, -56, 94, -128, -110, -128, -42, -26, -3, -39, -85, -69, -2, 1, -65, -56, 53, 15, -49, -24, -126, 13, -102, 2, 5, -89, -128, -100, -48, -44, -123, 43, 38, -12, -53, -56, -99, -85, -57, 9, -87, -96, 16, 32, 58, 5, -94, -9, -22, -63, 13, -17, -128, 2, -20, -6, -32, -76, -42, -72, -10, 100, -107, 76, -75, -14, -40, 18, 24, -93, -113, 26, -2, -44, 93, 25, 17, -89, -128, 48, -53, -39, 39, -6, -69, -47, -50, -26, -64, 2, 19, 59, -117, 59, -128, 3, 15, -1, 29, 14, 6, 22, -4, 17, -20, 3, 61, 12, -59, -23, -12, 5, 12, 12, -17, 3, 18, 6, 20, 11, -18, 17, 71, 75, -42, -11, -15, 5, 35, -22, -53, -6, 26, -9, 25, 17, -14, -1, 62, 17, -5, -3, 4, 6, 12, -69, -9, -2, 62, -12, 23, 1, 3, -1, 11, -22, 5, -3, 22, 15, 19, -70, -23, 1, 51, -21, 17, 19, -20, 1, 1, -3, -42, -20, -1, -5, 26, -80, -21, 17, -19, -4, 17, 1, -31, 14, 31, -11, -25, -11, 1, -11, 14, -115, -103, 4, -18, -18, 62, 9, -11, -1, 67, 1, 4, 3, 4, -4, 15, -76, 11, 3, 1, 2, 42, -2, -35, -18, -26, 9, 51, -5, 39, -20, 12, -9, 33, 15, 5, -1, -4, 17, -1, 9, 37, 18, -19, -6, 12, -11, 3, -12, 81, -2, 4, 12, -12, 12, 21, -9, 29, 5, -3, -18, -35, -3, 6, -25, -77, -15, 19, 19, 4, 2, 25, -14, 55, 5, 14, -17, -17, -12, 2, -22, -40, 5, -5, -9, 20, 23, -9, -1, 11, -4, 6, -11, 5, -4, 11, -23, -71, 3, -5, -42, 6, 26, -1, -3, 1, -3, -12, 9, 3, 4, 9, -77, -33, -9, -55, -31, 1, -17, -1, 1, 14, -40, -48, 4, -12, -5, 22, -111, 2, -6, -51, -6, 51, 17, -12, -1, 55, -15, 15, -15, 1, 3, 11, -76, 20, 14, -12, -18, 59, 1, -42, 1, -26, 2, 50, -5, 35, 2, 9, 19, -35, 5, 20, 1, 22, 15, 33, 17, 12, 26, -21, -3, 12, -2, 23, -9, -61, 6, 51, 4, 21, 40, 26, -20, 26, 18, 14, -11, -4, -5, 11, 1, 20, 3, 23, 9, 9, -3, 61, -5, 22, 5, -21, 1, 33, -3, 3, -12, 11, -6, -6, 26, -3, -18, 70, 14, 11, 17, -1, 2, -15, -11, 9, 42, 11, -5, -5, 12, -17, -4, 37, 15, -18, 14, -3, -6, 3, -6, 3, -29, 21, 1, -26, -14, 5, -15, 44, 29, 25, 42, -31, -14, -12, -15, 6, -49, 22, -17, -33, -2, 21, 2, 71, 17, 37, 49, 21, -5, -29, -4, 19, -20, 37, -3, 1, 4, 48, -1, 73, -1, 19, -63, 55, 17, -19, -18, -11, 40, -23, 33, 62, 25, 19, -3, 15, 21, 2, 42, -9, -5, 33, -4, 35, 18, -14, 19, 42, 33, 25, 21, 17, 21, 49, 29, -39, -2, 23, -11, 26, 9, -5, 21, 42, 18, 20, 25, 44, 1, 23, 26, -26, 5, -21, -6, 31, 12, 9, 17, 33, 15, 1, 19, 62, 14, -1, 15, 1, -9, -23, -1, 23, 71, 71, 14, 31, 21, -2, -15, 18, 26, 1, 20, -29, -9, -11, -12, 35, 17, 25, -5, 6, 14, 6, 1, 29, 5, 20, 37, -20, 9, -62, -4, 14, 4, -3, 1, 9, 39, 12, -3, 4, 11, 59, 59, 14, -9, -60, 4, 19, -22, 9, -1, 35, 31, 39, 9, 19, -2, 25, 33, 40, 9, -20, -5, -37, 55, -37, 11, 82, 35, 12, -14, 68, 42, -4, 4, 40, 4, 39, -18, 17, 67, 12, 1, 85, 39, 1, -22, 55, 3, 56, 56, 1, 2, 44, -2, 3, 40, 1, -14, 60, 23, 9, -17, 12, -5, 77, 31, -17, -14, 4, -4, 19, -1, -1, -1, 23, 6, 4, 12, -6, 22, 29, 53, -21, -2, 1, -4, 2, 31, 12, 12, 19, 2, -11, 6, 12, 21, -14, 35, -37, 15, 1, -19, 12, -20, -71, 1, -9, 19, 17, -18, 26, 29, 1, 19, -80, 5, -62, -20, 17, -19, 9, 1, 6, 48, 3, 9, 29, -17, 51, 70, -5, 9, -82, 1, 6, -50, 22, -1, 40, 53, 9, 1, 2, 14, -39, 31, 44, 9, -29, -1, -25, 87, -12, -1, 48, 70, -26, -26, 51, 35, -15, 82, 84, -14, 60, -5, -1, 92, 80, 4, 25, 70, -11, -12, 82, 17, -4, 70, 102, -11, 48, -6, 19, 53, 76, -15, 19, 29, -6, -1, 48, -6, 116, 12, -1, -6, 50, -3, 39, 40, 40, -19, 1, 3, -3, -4, 26, -1, 70, 9, -15, -19, 22, -6, 12, 31, 85, 3, 3, 5, -19, 4, -12, 29, 35, 39, -40, -5, -15, -31, 18, -1, 3, 15, -2, -3, 5, -19, -2, 26, 14, 61, -49, 1, -97, 3, 17, -39, 25, -5, 12, 17, 4, 3, -21, 26, -5, 71, -26, 18, -91, -5, 23, -60, 20, 11, 26, 5, 20, -5, -42, -12, -22, 26, 37, 6, -42, -9, -12, 80, -11, 40, 75, 53, 23, 12, 33, -11, -42, 75, 87, -17, 87, -15, -18, 119, 19, 31, 53, 51, -14, 2, 53, 1, -31, 76, 68, 6, 68, -21, -9, 26, 82, -14, 42, 55, -21, -3, 26, -17, 26, 67, -31, -14, 99, 1, 3, 42, 22, 14, 22, 42, -19, 9, -11, -1, 70, -3, -20, -11, 35, -29, 21, 20, 9, 2, 51, 9, -23, -11, -17, 11, 25, 12, -1, 1, -40, -9, 14, -17, 18, -3, 23, 4, -9, -5, -22, 9, 14, 61, 6, 2, -53, 1, 15, 1, 15, -6, 82, 20, -11, -9, -26, 3, 5, 125, -26, 3, -99, -3, 22, -18, 18, 15, 35, 14, 1, -2, -37, 1, 5, -9, 4, 6, -56, -22, 1, 19, 98, 21, 82, 19, 63, 39, 29, -15, -85, 50, 62, -14, 109, -18, -17, 102, 92, 15, 88, 39, 21, -2, 71, -5, -61, 59, 39, -17, 84, -20, -21, 12, 56, 17, 59, 33, 17, 4, 48, -31, -48, 55, -69, -1, 84, -20, 29, -2, 61, 3, 35, 14, 14, 4, -40, -26, -4, 15, -50, -18, 25, -20, 12, 49, 11, -9, 69, 22, -14, 1, -97, 11, -9, 35, -5, 15, -20, -29, 11, -5, 31, -6, 80, 26, -23, 14, -75, 4, -33, 69, 12, 6, -70, -20, 2, 4, 5, -23, 121, 85, -44, -1, 11, 4, -37, 44, -4, 1, -111, -9, 33, -15, -2, -6, 42, 21, -67, 5, -14, -1, 125, -2, -9, -14, -88, -15, 20, -9, 73, 1, 98, -39, 37, 17, 37, -31, -3, -44, 115, -3, 127, -23, 14, 68, 40, 23, 75, -1, 19, 23, 26, -1, -42, 5, 70, -1, 116, -2, -14, 19, 42, 40, 62, 14, 20, -21, 76, -1, -39, 15, -82, 12, 88, -15, -12, 1, -15, 12, 55, 11, 14, -9, 42, -15, -15, 22, -75, 9, 49, -23, -25, -25, -19, 5, 77, 21, -2, 5, -49, -19, 9, 29, -71, -14, -17, -5, 15, 17, 18, 17, 85, 14, -1, 1, -128, -3, -63, 80, -40, -2, -18, -11, 11, 9, 9, 2, 126, 85, -56, 3, -128, 1, -127, 127, -51, -17, -25, -17, 6, -35, 23, -4, 112, 90, -76, 12, -128, -1, 18, -33, -23, -3, -75, -15, 1, -29, 20, 2, 22, -25, 1, 6, 23, -29, 15, -9, 127, 4, 97, -6, 11, -12, 80, -6, 60, -18, -1, 14, 25, -14, -6, -42, 127, 1, 112, -9, -12, -2, 25, -12, 40, -35, 12, -1, 25, -14, 9, 6, -26, -17, 121, -4, -14, -11, -19, -26, -5, 11, 22, -14, 44, -1, 3, -20, -71, -9, 70, 3, -17, -62, 5, -12, 31, 2, 50, -1, -17, -12, 11, -42, -21, -2, -21, -12, -29, -76, 5, -2, 62, -25, 22, 2, -51, -20, -4, -21, -31, 14, -49, -11, 9, -5, 33, 6, 126, 15, -20, 15, -128, 29, -128, 33, -55, -1, -20, -29, 26, 53, 19, 2, 127, 42, -115, -1, -128, -11, -63, 70, -59, -1, -20, -6, 1, -5, -9, 20, 39, -40, -9, -3, 33, -17, -3, -2, 82, -1, 82, 6, 19, -17, 11, 12, 42, -14, 4, 11, 17, -9, 1, -3, 105, -2, 94, -9, 40, -17, -50, -3, 42, -20, 6, 6, 1, -1, 14, 3, -12, 1, 116, -20, -20, -25, -112, 1, -15, -21, -18, 37, 21, 2, 9, -5, -20, -26, 70, -11, -18, -69, -128, -29, -14, -1, 3, 9, -14, -3, 33, -80, 5, -1, 25, -17, -6, -106, 6, -31, -1, -59, 18, -18, -84, -9, 51, -99, 40, -4, 69, -18, 1, -99, 11, -39, 23, -75, -17, 3, -128, 17, -56, -116, 33, -5, 71, -6, 11, -14, 22, -19, 31, -94, -109, -20, -128, -5, -115, -102, -56, 2, 116, -15, -18, -9, 17, -2, 29, -17, -14, -17, 4, -12, 1, -15, 51, 14, 42, 5, 18, -14, 23, -20, 17, -11, 4, -6, -2, -1, 6, -20, 49, -4, 77, 1, -1, -11, 23, -18, 19, -9, 1, -1, -18, -15, 12, -49, 37, -20, 71, 2, -21, -19, -49, -14, -20, -18, -20, -17, -20, 18, 26, -33, -77, -14, 70, -15, 3, -85, -84, -48, -25, -5, -67, -15, 1, -11, 70, -63, 11, -5, 20, -11, -39, -128, -60, -107, -22, -59, -84, -22, -1, -21, 81, -115, 75, -5, 81, -22, 15, -128, -12, -2, -42, -116, -77, -18, 55, -5, 35, -128, 87, -3, 125, 9, 9, 35, 18, -77, -31, -125, -128, -56, 14, 3, -87, -128, -31, 6, 127, -81, 35, -51, -56, -23, 9, -78, -66, 97, 27, -27, -69, 31, -68, -9, -20, -45, 127, 122, 89, -51, 35, -57, -85, 30, -61, -125, -4, 112, -51, -67, -81, -73, -1, -17, 5, -29, 10, 32, -29, 9, 14, -79, -33, 19, -89, -127, -30, -78, 64, -114, -36, -112, -80, -120, -90, 54, -6, -94, 49, 9, -79, -68, -30, -74, 30, -128, 5, -36, 1, -97, -47, 3, -29, -11, -6, -14, -113, 10, -106, -38, 40, -80, 53, -38, -21, -69, 3, 127, -128, -92, -71, 3, -81, -3, -122, -52, 80, -128, 45, 6, 44, -85, -48, 16, -80, -116, 28, -88, -89, -88, -111, 22, 123, -64, 1, 28, -9, -103, -19, 22, 2, 32, -44, -6, -32, -31, -113, -30, 77, 31, 17, -18, 17, -49, -1, 94, 68, -77, -45, -108, -23, -103, -48, -91, 33, 1, 9, -91, -34, 18, -84, 114, 32, -43, 3, 79, -73, -7, -56, 21, 28, -74, 6, -5, -14, -57, -90, 57, 72, -72, -53, -19, 7, 14, -10, -34, 23, -95, -2, 15, -22, -4, -33, 107, -44, -112, -46, -17, -39, -91, -52, -79, 28, 9, -38, -78, -1, -26, -96, 39, -44, -22, -80, -15, -53, -10, -99, -128, -7, -45, -7, 3, 3, -128, 6, -48, -68, -29, -122, 73, -96, -15, -128, -16, 110, -96, 20, -84, 11, -16, -7, 18, 84, -28, 11, 78, -16, -14, -116, -99, 110, -57, 77, 3, 35, -128, -10, 84, 127, 1, -77, 35, 38, -112, -123, -128, 96, 5, 9, -120, -33, -78, -6, 57, 38, -106, -43, 68, 46, -49, -86, -28, 127, -20, -4, -29, -18, -128, -20, 45, 127, -39, -29, -48, -79, -49, -88, -128, 22, -61, -110, -34, -52, -109, -4, -17, 64, -52, -45, -88, -92, -92, 112, -64, 127, -60, -116, -36, -60, -66, -4, -30, 66, -16, -103, -22, -67, 34, -128, -66, 49, -66, -67, -71, -57, -85, 7, -27, -11, -61, -128, -53, -125, -23, -118, -110, 74, -73, 80, -22, -53, -43, -80, -86, 44, -87, -53, 33, -21, 7, -92, 28, 106, 1, 52, 1, -16, 19, -21, 53, 2, -60, -113, -16, -118, -28, -99, -56, 120, -72, 125, 54, 27, -11, -40, 3, -49, -81, -85, -16, 5, -1, -69, 4, 95, -74, 44, -105, -49, -23, -54, 102, 23, -22, -73, 11, -29, -4, -20, -92, 72, -49, 48, -31, -20, -128, -3, 64, 91, -90, 21, 28, -72, -2, 35, -34, 47, -68, -16, -35, -17, -87, -30, 103, 117, -44, -85, 16, -73, -6, 101, -12, 86, -84, -97, -15, 6, -91, -106, 14, 22, -48, -4, -27, -128, -88, -101, -48, 69, -16, -47, -106, 81, -38, -12, -14, 53, -40, -67, 2, -31, -88, -125, -74, -5, -80, -68, 31, 52, -66, -31, -26, 3, -45, -86, 12, -128, -21, -124, 7, 51, -57, -35, -35, -5, -54, -12, 11, 29, -128, -35, 21, -61, 27, -60, -1, 69, -36, 11, -43, -92, 23, -27, 51, 36, -15, -45, 17, -35, -105, -109, -96, -60, -105, -48, -61, 51, -102, -85, 112, 30, -84, -60, -1, -1, 1, 89, -72, -15, -10, 127, -128, -18, -86, -123, -43, 17, -71, -26, -5, -17, 35, 127, -107, 43, -53, 22, -9, -22, -128, -101, -27, -88, -15, 11, -12, -16, -12, 106, -23, 34, -113, -101, 14, -29, -26, -57, -26, -36, -45, -39, -23, -61, -89, -79, -54, 27, -23, -16, 21, 66, -61, -38, 28, 15, -2, -61, 49, -116, -9, -68, -90, -10, -60, -123, -31, -26, 4, -11, -43, -28, -44, -73, -3, -11, -6, 46, 28, 22, -91, 46, 53, -35, -44, -16, 16, 35, -23, -39, -27, -105, 34, -85, -128, 43, -31, 1, 47, -79, -20, -28, 60, 35, -47, -57, -79, 27, -84, -128, -49, -86, -20, -95, -61, 127, -54, -67, 81, 94, -43, -3, -85, 20, -16, 67, -72, -74, 15, -81, -47, -45, -46, -94, 11, 116, -30, -81, 26, -88, -26, 127, -111, 23, 10, 74, -19, -4, -51, -128, -22, 108, -14, -108, 19, -114, 43, -105, -35, 118, -77, 12, -46, -29, -123, -10, -29, -66, -56, 30, 30, -51, 49, 26, -97, 54, -80, -72, -43, 1, -60, -74, 36, -4, -71, -15, 91, -80, -27, -11, -73, 60, -89, -49, -72, -52, -107, -30, 5, -11, -49, 51, 71, -86, -102, -96, -127, -1, -78, -43, -56, -27, -3, 27, 11, 12, -114, -14, -10, 2, -61, -119, -29, 103, -6, 88, -34, 61, -51, 10, -52, -26, -36, -12, -16, -64, -2, -127, -35, 81, 17, 60, -67, 7, 7, -40, 77, 114, -84, -97, 117, -52, -28, -113, -92, -91, 1, 123, -95, 20, -51, 1, 122, 81, -81, -38, 15, -35, -12, 125, -47, 89, -127, 53, -46, 4, -44, -128, -18, 61, -108, -45, 14, -49, 26, -92, -110, 60, -31, 6, -18, -18, -20, -89, -16, 22, 14, -71, -72, -67, -103, -68, -128, 110, -128, 53, -110, 30, -90, -33, -2, -26, -80, -11, 17, 16, -11, -128, -105, 119, -90, 127, -26, 44, -29, -109, -21, 5, -101, -45, -7, -19, -51, -116, -116, 102, -26, -80, 39, -40, -21, -14, 9, -34, -68, -99, -51, -44, -9, -96, -85, 60, -17, 113, 31, 30, -52, -56, -91, 29, -22, -28, 40, 31, 40, -49, -45, -48, -72, 39, -1, -128, -7, -2, 102, 103, -73, -60, -92, -60, -77, -10, -90, 80, -45, 27, -22, -12, -21, -88, 54, 102, -108, 4, -6, -40, 1, -11, -64, 105, -91, 86, -18, -28, -15, -80, 11, 64, -73, -23, -3, -90, 35, -103, -119, 114, -119, -36, -60, -44, -88, -38, -36, -6, -117, -97, -20, -109, 22, -40, -38, 78, -32, 81, -103, 12, 6, 15, -39, 53, -64, -27, -29, 6, -9, -114, -60, 77, -78, 116, -87, 21, 36, 12, 26, -73, -99, 4, 34, -20, -20, -128, -7, 117, -87, 14, -39, 2, -14, -34, 64, 57, -34, -60, -11, 31, -79, -30, -128, -1, -5, 14, 31, -128, 26, -116, -30, 36, 40, -92, 31, -11, -12, -128, -102, 53, -21, 125, -92, 7, -128, -92, -1, 43, 28, -16, -20, -5, -23, 53, -56, 28, 14, 127, -15, -38, -128, -35, 99, 31, -52, -31, -44, 7, -18, 112, -103, -2, -26, -6, -12, -1, -128, -12, 5, 95, -67, 18, -43, -128, -57, 92, -79, -23, -92, 77, -27, 127, -49, -35, -2, 69, -3, -125, -31, -128, -57, -31, -80, 91, -20, 81, 51, -90, -35, 3, 12, -89, 4, -12, -52, -111, -46, -40, -128, 46, -78, -92, 53, 35, -87, 26, 17, -88, -3, -125, -16, -88, -1, 3, -57, 107, -81, -61, 2, -89, -39, -67, -4, 11, -47, -53, -72, 29, -61, -96, -80, 31, 16, 66, -21, -44, 39, -53, 10, 54, -78, -28, -36, -22, 1, -116, -12, 3, 10, 89, -72, 114, -20, -128, -5, -128, -72, -1, 106, 20, -94, 90, -51, 72, 35, -43, -71, 17, -74, 5, 48, -80, -40, -71, -44, -19, -66, 77, -94, 60, 16, 31, -28, 30, -106, -99, -3, 112, -30, -18, -11, -128, -7, 36, -66, -106, -90, -78, -6, -72, -128, 1, -57, 78, -21, 9, 71, -128, -77, -26, -92, -26, -90, -44, 77, -78, -12, -39, -11, -47, -91, -21, -20, -78, -66, -30, -57, -43, -78, -27, -96, 21, 23, -87, -16, -32, -9, -30, 5, -116, -81, -111, -66, 11, -118, -128, -46, -85, 3, -18, 77, -36, 30, -77, 38, -51, -46, -45, -128, 30, -27, 85, -11, 14, -22, 7, -47, -102, -107, -92, 32, -29, 21, -40, 19, 31, 10, -7, 28, 40, 4, -73, -44, 127, -29, -46, 101, -87, -74, 78, -54, -69, -11, -110, -79, 1, -67, -128, 15, 127, -54, -45, 119, -86, -21, 56, -21, -49, -92, 90, -26, -125, -30, -113, 11, 127, -34, -94, 127, 12, -57, -128, -101, -36, -92, 127, -23, -88, -128, -128, -61, 47, 3, -96, -34, -18, -36, -128, -128, -81, -79, 101, -30, -128, -20, -33, 66, 81, -33, 22, -87, -103, -105, -47, -60, 39, -49, 88, -33, -49, -107, -94, 60, 125, -46, -90, 36, -60, -81, 35, -85, 1, -26, 51, 84, -7, -69, 32, 19, -128, -114, 52, 72, -18, -32, 1, -60, 27, -38, 85, 7, 96, 6, -99, 15, -1, -49, -113, 81, 35, -26, -114, -68, 17, -11, 99, -18, -128, -45, -45, 45, 46, -103, 1, 107, -78, 73, -90, -106, -43, -21, 57, -3, 87, 20, -86, 6, 127, -1, -16, 31, -78, -71, -112, -44, -122, -19, 97, 48, -66, -45, -18, 36, 29, -30, -36, -14, -79, -87, -35, -80, 32, -107, 38, 33, -22, -61, -10, 16, 116, -86, -71, 7, -33, -28, -86, -28, 33, -52, 89, 22, -73, -7, -35, -2, 116, -56, -90, 21, -32, -49, -79, -88, 38, -10, -15, -53, -45, -80, -68, -64, -86, -86, -26, -40, -78, -64, -30, -29, 118, -67, 26, -96, -12, -22, -33, -6, -128, -67, -23, -38, -87, -78, -40, -20, 127, -71, 127, -3, 9, -54, -111, -10, 2, -86, -28, 6, -12, -23, -6, -72, 32, -8, -80, -117, -10, -3, -45, -46, -35, -101, -45, -22, -56, -89, 5, -56, -27, 46, 65, -39, -93, -83, -93, 5, -45, -18, -49, -1, -40, -122, -16, 11, -15, -22, -17, -24, 73, -56, -41, 45, -37, -74, -91, -40, -17, -39, -73, -97, -61, -22, -36, -22, -1, -12, -35, 17, -29, -95, -35, -18, -35, -93, -32, 40, -1, 68, -12, -80, 29, -45, -102, -69, -40, 1, -15, -4, -56, -103, -35, -79, 3, 73, 23, -39, -15, -39, -46, 23, 37, -18, 18, 46, -72, -39, -93, -102, -79, -65, -63, -110, -81, -79, -109, 77, -79, -93, 82, -6, -37, -66, -23, -50, -61, -22, -73, -10, 15, 12, -4, -29, 5, -119, 127, -2, 1, -39, -93, -86, -48, -53, -86, -113, -10, -128, -28, -40, -43, -113, -77, -61, -36, -77, -53, -119, 24, 86, 93, -69, -23, -81, 18, 85, -12, -23, -128, -96, -46, -48, -35, -40, -6, -83, -36, -43, 61, -41, -125, -77, 56, -37, -65, 33, -28, -93, -65, -56, -97, 41, -18, -36, -61, -68, -90, -46, 6, -58, -69, 15, -122, -49, -25, -25, -12, -66, -86, -103, -60, 1, -49, 29, 77, -73, -80, 32, -113, 6, -45, -12, -93, -126, -14, -22, -58, 24, -106, -41, 7, -4, 4, 41, -128, -46, -126, -61, 122, -61, -77, -96, -53, 16, -43, 33, -72, -58, 20, 15, 16, -56, -15, -7, 4, 16, 11, -43, 12, -63, -48, -20, -85, -29, 14, 46, -66, -63, -46, -72, 16, -82, 70, -58, 24, -48, 20, 12, 20, -51, -127, -5, 90, 12, -91, -98, 23, -89, -40, -128, 1, -41, -105, -68, -56, -69, -76, -70, 127, -128, 121, -2, -56, -45, -10, -128, 60, -46, -76, -1, 7, -91, -61, 20, -103, -103, -5, 6, 8, -103, 10, -12, 40, -20, -128, -14, 16, 23, -128, -10, -91, -27, -73, -7, 43, -81, -60, -12, -48, -12, -22, -8, -2, -70, -90, -65, -56, 6, 20, -77, 36, -82, 91, -116, 14, -43, 14, -33, 82, -125, -73, -12, 33, -39, 51, -43, 127, -72, -43, -103, -14, -113, -63, -7, 41, -125, -56, 11, 4, -101, 109, -69, -29, -103, 65, -41, 127, -12, 24, 12, -46, -29, -121, 6, -73, -86, -14, -35, -33, -77, 45, -37, 14, 36, -12, -25, 14, -65, -102, -7, 14, -128, -5, -39, 18, 4, 37, 28, 11, -25, 8, 43, -74, -128, -70, -2, -7, -125, -17, 10, 5, -128, 90, -128, 83, -83, -109, 24, 102, -128, -49, 91, -2, 12, 127, -125, 24, 33, -3, -22, 14, 11, -98, -24, -80, -43, -80, -65, -128, -35, -74, -102, -12, -33, -14, 1, 80, -18, -48, -82, 37, -93, -128, -74, -128, -105, -10, -37, -33, -125, -29, -123, -1, -58, 14, 18, 66, -121, -18, 2, -10, 11, 70, -91, 14, -61, -16, -22, -66, -98, -46, 49, -51, -74, -70, 73, 2, -35, 106, -117, -14, -115, -8, -3, 127, -51, -89, 93, -35, -60, -115, 16, -83, -41, -70, -73, 80, -77, 127, -60, 41, -61, -2, 24, 5, -76, -23, 76, -12, -12, 95, 6, 40, -18, 37, -61, 41, -53, 16, -18, 48, -105, 40, -20, 5, -58, 127, -36, -58, -41, -32, -95, 25, -128, -12, 11, -2, -128, -12, 77, -12, -66, 72, -39, 4, -24, -10, -27, -36, -20, -22, -39, -56, -45, -93, 45, -56, -98, -14, -128, 41, -82, 15, -128, 79, -60, -72, -56, 12, 11, -83, 4, -77, -83, 6, -32, 96, 17, -35, -56, 41, 12, -83, 101, 12, -70, -68, 12, -85, -46, 89, 11, 101, -103, -95, -102, 18, 1, -97, -82, -6, -17, -128, -20, -51, -49, 113, -41, 56, -85, 48, -82, 2, -66, -96, -12, 65, -49, -76, -3, -28, -41, -96, -73, 77, -115, -37, -51, 103, -77, -116, 12, -29, -43, -41, -98, 24, -29, 74, -128, -6, -49, -1, -113, -74, -46, -72, 45, 68, -103, -92, 17, -76, 49, 127, -116, 20, -93, -22, -121, -41, -128, -41, -63, -92, -73, -82, 58, -91, -50, 115, -1, -56, -125, -12, -22, -1, -53, -23, 7, -3, -2, -2, -80, -110, -46, -32, -79, 80, -63, -89, -95, -82, -128, 3, -41, 15, -39, 12, -7, -10, -15, -33, -50, 79, -97, 85, -74, 16, -107, -128, -7, -45, -128, 16, -8, 15, -61, 4, -128, -35, -81, 61, -41, -105, -36, -3, 17, 46, -48, -25, -6, -10, -36, -17, -103, -98, -123, -16, -128, -97, -93, -90, -7, -6, -81, -86, -97, -53, -110, -58, -72, 69, -56, 4, -25, 24, -37, 14, 36, -4, -14, -128, 43, -11, -18, -107, -16, -41, -4, -33, 46, 27, -46, -12, 12, -36, -56, -109, -36, -118, -8, 37, -41, -25, -14, -14, -29, -24, -24, -106, 37, -2, -15, -48, 6, -12, 3, -80, -8, 1, 1, -16, 4, -5, 14, -97, -1, 41, -102, 11, 8, -48, 18, -85, -115, 10, -20, 24, -56, -61, -11, -93, 63, 14, -97, -14, 35, -14, -109, -61, 1, 48, -11, -28, -51, -18, -66, -113, -83, -16, 4, 14, -14, -93, -60, -28, -39, 7, 1, 48, -53, -1, -93, -109, -10, -2, 28, -56, 49, 10, -105, 68, -93, 96, -43, 70, -128, 82, -46, -80, -12, -1, -77, -69, 24, 12, -77, -69, -102, 61, 12, 8, -46, 4, -53, -3, -46, 63, -95, -4, 22, 36, -37, 121, -56, -40, -89, 14, -115, 23, -53, -83, -73, -12, -85, -118, -48, -56, -35, 50, -20, -7, -95, -12, -20, -18, -82, 18, 22, -10, -53, -46, -27, -80, -82, -113, -46, 7, -24, 15, -89, 1, -3, -17, -20, -45, -73, -46, -43, 6, -43, -60, -6, 5, -56, -40, -39, -8, 2, -15, -18, -14, -33, -128, 3, -28, -65, -7, -83, -41, -53, 37, -108, -25, -61, -92, 1, -12, -61, -58, -15, -49, -90, 68, 6, -27, -77, 20, -10, -37, 40, -41, 5, -2, -63, 7, -4, -3, -89, 108, -105, -46, -86, 66, -40, 127, -1, 2, -60, -22, -24, -74, 27, -95, -22, -28, 41, 45, -92, 3, -91, -14, -125, -35, 18, -6, -28, -128, 18, 35, -73, -16, -58, -93, -128, 18, -61, -97, -12, -29, 51, -56, -61, -118, -23, -32, -103, -12, -113, -27, -22, -58, -90, 12, -128, -1, -91, 73, -95, -127, -36, -17, -107, -92, -45, -5, -3, 4, 1, -17, 5, 15, -105, -76, -101, -49, -8, -33, -18, -27, -40, 18, -128, 51, -20, 61, -121, -6, 79, -28, -18, -58, -1, -5, 36, 32, -115, -5, -125, 46, -41, 32, -46, -128, 1, -61, 25, -1, -4, -107, -86, 33, -32, -4, -39, -83, -65, -25, -82, -107, -56, -10, -79, -109, 33, -23, -115, 127, -61, 28, -91, -80, -43, 116, -79, -16, 17, 3, -1, -68, 11, -72, -53, -77, -46, -2, 5, 7, -95, -41, -115, -37, 77, 20, -66, -93, 12, 14, -119, 23, -61, -60, -82, -8, -92, 29, -109, -16, -22, 35, 22, 2, 102, 27, 16, 6, -36, -77, -66, 8, -56, 14, -92, -11, 1, 36, -74, -101, -4, -51, -128, -70, -61, 66, -24, -41, -8, 14, -6, -8, -29, -51, 17, -15, 10, -125, -61, -1, -85, 48, -76, 7, -43, 20, -128, -53, 5, 22, 41, -105, -63, -128, -20, -81, -41, 29, -118, 45, 16, 20, -93, -90, 40, -6, -89, -98, -49, -41, 7, -33, -74, -73, -39, 15, -128, -37, -128, -98, -73, -10, -76, -93, 16, -91, -32, 61, -63, -16, -16, -43, -23, 18, -126, 28, -32, 11, -85, 11, 14, -56, -46, -16, -66, -72, -96, -14, 49, -27, -109, -27, 105, 91, -83, -76, -18, -18, -20, -77, -80, 70, -20, -18, -3, 3, -66, -117, -58, 6, 1, 22, -50, -40, -41, -128, 17, -18, -56, 56, -37, 12, -27, -29, 39, -6, 5, -35, -27, -48, -128, -72, -15, 11, -63, 43, -128, 5, -83, -108, -27, -72, -89, -91, 60, -11, -72, -41, -2, 73, -46, 27, -51, -37, -24, -14, 2, -18, -61, -83, 29, -69, -93, 41, -39, 68, -128, 77, -128, -1, -7, -72, -33, -90, -61, -14, 35, -27, -128, 127, 14, -7, -41, -41, -115, -41, -113, -5, 11, 15, 20, -74, 27, -8, -11, 17, -1, -56, -1, -11, -63, 79, 41, -95, -15, -39, -37, -28, -61, -61, -83, 45, -39, -36, -46, 48, -43, 121, -40, 45, -58, 56, -18, -95, 25, -29, -61, 53, -56, -82, 8, 2, 20, 56, -74, -1, -4, 7, -15, 28, -12, -35, -128, -16, -91, -93, -1, -25, -56, -22, 6, -2, -14, -3, -96, -18, -95, -72, -8, 83, -6, -28, -60, -7, -128, -56, -16, -33, 83, -20, -70, -128, -48, -46, 4, -11, -39, 20, -7, -18, -35, -81, 40, -103, 32, -82, -43, -79, 20, -10, -4, -1, -72, 1, -72, -83, -49, -46, -61, -108, -39, 66, -40, -1, -53, -56, -45, 60, 7, 3, -93, 40, -63, -33, -128, -117, -17, -56, -61, -20, 73, 22, -46, 46, -128, 24, -4, -92, -72, 110, -89, 15, -66, -5, -12, 5, -95, -83, -128, -46, -59, -24, 66, 1, -128, 46, -37, 94, -16, -69, -84, -66, 40, -26, -18, -115, -128, 9, 78, -26, -67, 80, -116, -14, 21, 21, -83, -21, 16, -89, -41, -105, -13, 24, 21, -19, -76, -7, -54, -111, 101, 87, -32, -92, 1, 79, 13, -77, -128, -36, -2, -61, -89, -20, -16, -44, -1, -44, -89, -2, -10, -111, -52, -91, -66, -7, 23, 2, -71, 73, -41, -71, 16, -44, -84, -39, -2, -59, -77, -36, -102, -34, 22, 13, -21, -95, 33, -84, 14, 48, -108, -87, 4, 10, -33, -127, -122, -5, -36, -11, 15, -43, 23, -94, -2, 24, -9, -5, -36, -40, -102, -87, -61, 16, -112, -75, -128, 64, 33, -109, 84, -11, -15, -48, 99, -82, -90, -112, -64, -39, -71, 38, -56, 29, -10, -24, -48, 37, -13, -79, -24, -33, -20, -97, -9, 59, 19, 14, -90, -13, 16, -23, 14, -24, -128, -28, 2, -44, 16, -106, -18, -29, 9, 7, -126, 15, -14, -73, -14, 28, -84, -42, -18, 41, -71, -71, 2, 70, -40, 30, -111, 30, 95, -92, 66, -56, -37, -91, -64, 67, -59, -23, -38, 64, -97, 11, -121, -32, -102, -107, -75, 54, -94, -9, -14, -43, -110, -8, -105, 11, -7, -22, 91, 44, -18, -128, -42, 92, -16, -107, -1, -79, -109, 36, -32, -16, -8, 44, -48, 22, 4, -128, 39, -75, -84, -113, -28, -48, -82, 11, 9, -26, -126, -23, -73, -77, 95, -97, 2, -30, -48, 2, 15, -94, 38, 10, -82, -19, -107, -41, -31, -32, -5, -70, 70, 14, -19, -7, 2, -33, -24, -115, -128, -16, -94, -7, -44, -42, -86, -59, 15, -9, -102, -95, -5, 26, -9, -83, -128, 16, -91, -61, -128, -7, 2, -103, 26, 47, -126, -128, 43, 16, -73, 26, -128, -18, 21, -20, -75, 40, -5, -95, 41, 79, -59, -92, 41, 7, -2, -47, -91, -20, -14, 5, -64, 43, -9, -83, -2, 1, -22, 19, -10, -39, -47, -28, -128, -36, -33, -42, -128, 37, -90, -91, -23, -79, -23, -64, -8, 23, -105, 14, -56, 22, 95, 15, -21, 15, -52, 8, -29, 10, -13, -54, 87, -101, -102, -61, -29, 43, -22, -99, -95, -30, -41, -54, 39, -41, -1, -53, -52, -22, -107, 36, -75, -86, -110, 59, -81, 47, -18, -82, -31, 20, 2, -54, 23, -75, -7, -128, -90, 34, -33, 14, 21, -66, -11, -128, 48, 18, -103, -16, -5, -97, -77, 8, -128, -67, -14, -22, -128, -101, -54, -97, -36, -46, -43, -79, 33, -23, -115, -5, -71, 8, 95, -2, 23, 61, -70, -61, -26, 8, -33, -5, 2, -18, -46, -61, -83, -37, 1, -52, -29, 61, -95, -46, 53, 10, -37, 14, -23, -67, -78, 23, -64, 38, 34, -48, -84, 1, -42, -128, 31, 5, -32, -128, -31, -2, -64, -29, -95, -30, -2, 32, -71, 30, -66, -8, 13, -16, -88, -64, -41, -13, -14, 38, -128, 102, 9, 80, -52, 79, -23, -111, 7, -11, -113, -43, -101, -53, -86, -95, -14, -37, -43, 33, -44, -78, -128, -48, -26, 54, -52, -110, -30, -69, -73, -22, -70, 79, -13, -33, -20, 40, -66, -15, -8, -10, -81, -91, -22, -40, -29, -75, -114, -59, 18, 26, -128, -20, -66, -59, -4, 14, 10, -128, 10, -5, -1, -48, -44, -46, 67, -26, -88, 44, -91, -71, -11, 23, -41, -34, 23, -34, -107, 86, -7, 5, 16, -13, -28, 11, -128, 7, 5, 61, -88, 10, 99, 41, -122, 4, -37, 10, 11, 40, -83, 1, -78, -128, 2, 13, -101, 40, -30, 11, -64, -22, -122, 42, 14, -7, -56, 11, -121, -108, 34, 33, -7, -78, 36, -84, -48, 84, -88, -34, -48, 44, -69, -92, -80, -21, -11, 26, -21, 5, 22, -107, -16, 18, -80, 37, -73, -83, -128, 10, 14, -67, -75, 16, -95, -84, 52, 64, 37, 2, -1, -2, 4, 39, 10, 47, -101, -67, -73, 4, -24, -128, -28, 32, -121, -28, -47, -36, -20, -4, -66, -66, -88, -127, 20, 32, -22, -21, 20, 21, -1, -115, -9, -32, -84, 19, -83, -32, -92, -128, 66, -23, -128, -13, -71, -23, -20, 16, -79, 53, -78, 29, -78, 26, -15, -84, 28, -33, -112, -24, -19, 33, -14, -31, 5, -91, 48, -77, -128, -11, -95, -48, -39, 1, -75, 11, -36, 10, -69, 22, -75, -9, 19, 8, -124, 4, -78, -14, -24, 87, -128, -64, 10, -2, -108, -34, -44, -11, 18, 26, -52, 20, -128, -15, -46, 38, -18, -125, -70, -18, -124, 48, -112, 95, -128, 22, -14, 26, -84, -73, -4, -5, -37, -111, -91, -32, 36, -11, -69, 11, -76, 2, -105, -38, -103, -89, 5, 43, -40, -91, -13, -19, -109, 41, -36, -4, -128, 1, -101, 93, -114, -95, -70, 11, -56, -40, 41, 16, -78, -8, -13, -36, -44, 84, -23, 2, -128, -88, 1, -10, -128, -66, 15, 76, -128, -128, -101, 18, -119, 19, -67, -8, -44, -119, -26, 38, -109, -83, -40, -82, 1, 16, -112, 11, 13, 67, -2, -21, -69, -81, -42, -16, -128, -22, 77, -11, -128, -73, -81, -23, -66, 77, -4, -7, -79, -128, -32, 71, 24, -108, -83, -95, -79, -59, 1, 22, 8, -13, -1, -32, -90, -22, -11, -23, -44, -2, 20, -108, -31, 76, -90, 5, -80, 31, -71, 47, -89, -118, 66, -7, -128, -109, 84, -37, -20, -61, -69, -1, -29, 15, -109, -88, -23, -48, -56, -77, -95, -80, -1, 7, -11, -15, -44, -93, 29, 41, -43, 44, -19, -128, 93, -7, -66, -66, -43, 8, -5, 36, -61, -8, 42, -4, -119, -11, -32, -93, 2, -13, -123, 66, 66, 28, -54, 21, 11, -14, 46, 19, -113, 37, -128, -115, 23, 31, -73, -69, -7, -13, -5, -24, -103, 33, -21, 95, -5, -42, -39, -23, 16, -36, -93, -114, -40, -88, 8, -39, -19, 16, -59, -13, -21, 33, -113, -10, -94, -43, -88, -79, 4, -23, -59, 30, -128, 5, 29, -94, -128, -19, -124, -26, -1, 5, -39, -113, -13, -87, 2, -31, -56, -30, -59, -8, -34, 48, -93, -44, -18, -78, -59, -124, -1, 42, 39, -31, -34, 77, -1, -39, -64, -23, -89, -73, 4, 10, -81, -128, 42, 31, -101, 33, -56, 26, -33, 44, -111, -70, -99, -70, 38, 102, -73, -39, -44, -26, -110, -40, -88, -11, -8, 41, -128, -15, -78, -99, -28, -66, -56, -82, -1, -13, -108, -128, -82, -5, -53, 5, -48, -1, -26, -101, -43, 52, -70, -28, 4, 82, -95, -22, -122, -9, 36, -91, -101, -64, -15, -66, 13, -40, -105, -93, -20, 33, -103, -26, -78, 1, -11, -75, -121, 46, -107, -30, -87, 1, -40, -43, 19, -66, -128, -22, -128, 24, 2, -59, -11, -5, -36, -76, 19, -24, -1, -46, -61, 20, -110, -7, -80, 40, -111, -29, -128, 48, -34, -121, -4, 28, 7, -107, -48, -23, 10, -40, -54, -32, -61, 2, -37, 48, -28, -112, -48, -42, -56, -128, 52, -29, -9, -99, -66, 67, -66, 11, -69, 22, -94, -28, -47, -52, -128, -48, -23, -76, -119, -54, -86, -26, -119, -71, -109, -56, -86, -115, 1, -20, -32, -116, 54, 56, -67, -39, 23, -19, -110, -23, -80, -39, -75, -125, 56, 40, -92, -30, -23, -29, -64, -86, -128, 15, -70, -22, -56, 36, -28, -54, -7, -16, -92, 26, 15, 15, -46, -14, -38, -32, 15, 48, -8, 83, -28, -93, -36, -22, -11, -32, 2, -19, -78, 29, -86, -78, -13, 53, -38, 2, -111, -83, -33, 38, -42, -54, -75, -10, -76, 16, -75, 83, 13, -38, -86, -75, -128, -11, 13, 19, -13, -8, 9, -2, -16, -111, -84, 92, -23, -53, -23, 42, -126, -78, -5, 54, 5, -111, 61, -11, 26, -128, -13, -46, -95, -21, -56, 2, -101, -95, -44, -22, 9, -111, 93, 21, -66, -59, -128, 84, -14, -43, -88, 36, -64, -118, -44, -44, -95, -112, -26, -77, 56, -54, -69, -42, -30, 79, -22, 20, -70, -43, -8, -40, -124, -14, 86, -26, -128, -127, -83, 66, 8, -4, -79, -9, -41, -128, 91, -28, -26, -128, 13, -94, -88, -21, -33, -70, -95, -59, -128, 23, -128, -4, 73, 15, -128, -71, -10, -34, -29, -19, 4, -86, -11, -40, -36, 18, -99, 13, -66, 47, -61, -90, -14, -128, -30, 34, -128, -29, -70, -20, -53, -71, -41, -31, -37, 47, -67, -5, -48, 102, 23, -53, -105, -4, -29, -31, -66, -31, -116, -8, 33, -82, -37, 23, -7, 23, 29, 47, -2, 10, -80, -7, -64, -94, -99, -83, 8, -23, -93, -70, -46, -56, -1, -40, -34, -22, -31, -37, -93, 52, -61, -77, 64, 90, -88, -108, 2, -32, -128, -106, -128, 30, -78, -106, -82, 1, -61, -99, 11, -52, -127, -80, -37, -41, -43, -88, -5, -90, -87, 21, -34, 23, -118, -71, -47, -40, -86, -94, -4, -21, -82, -1, -114, -26, -19, -37, -56, -42, -110, -108, 16, -22, -122, -128, 14, -14, -76, -53, -112, -7, -76, -90, -109, 9, 5, -103, -23, 23, -48, -84, 34, -46, -128, -30, -98, 66, -50, 23, -81, 14, -90, -73, -64, 13, -46, -123, 10, -84, 20, -3, -37, -59, 84, 28, -127, 76, -73, -68, 101, 6, -8, 2, 38, -128, -45, 29, -78, 95, 3, -59, -63, 100, -78, -59, 117, 86, -45, 29, -66, -99, -14, -6, -73, -23, -85, 12, -67, 31, -102, -105, 29, -27, -74, -45, 12, -68, -39, -24, -73, 127, -37, -28, -27, 3, -40, -98, 33, 71, -43, -8, -5, -127, -41, -31, -125, 68, -128, 64, -80, 59, -62, -98, 92, -72, -76, -21, 20, -97, 5, -49, -51, 125, -34, 10, -59, 127, -59, -21, 91, -49, -98, 26, -1, -103, -118, -46, -107, 39, -43, -14, -62, -3, -29, -7, -29, -87, -4, -91, -3, -63, -109, -43, -14, 1, -86, 14, -122, -34, -75, -81, -14, 4, -36, -43, 23, 47, -48, -45, 5, -54, -87, 33, -100, 70, -29, -110, 114, 124, -90, -47, -10, -71, -6, -45, -109, 90, -7, -12, 12, -23, -100, -40, 127, 127, -27, 3, -40, -29, -18, -46, -33, 80, -43, -18, 5, -45, -26, -103, 4, -127, -3, -45, -87, 5, -59, 27, 43, -128, -55, -24, -84, 34, -33, -37, 107, -123, -39, -128, -1, -117, -36, -113, -59, 70, -84, -84, -2, 2, -24, 1, -85, 67, -100, 8, -21, -109, -37, -26, -21, 9, -128, 28, 21, -37, -62, -86, 24, 14, -43, -128, -67, -103, -13, -109, 4, -84, -43, 48, 16, -109, -84, -41, -19, 59, -23, -14, -59, -34, -38, -54, -37, 103, -62, 127, -49, 29, -28, -109, 38, 37, 6, -31, 37, -4, -18, -54, -127, -75, -34, 125, -87, 91, -51, 33, 84, 76, -71, -39, -10, 74, -28, -50, -23, 67, -39, 14, -46, -6, -62, -24, 84, 14, -21, -124, -16, -39, 1, 127, -116, 5, -39, 75, -63, -28, -101, -20, -67, -8, -62, -21, 62, 14, -80, 38, -92, -4, -94, 1, -78, -12, -81, -78, 13, -64, -74, -113, 7, -2, -36, 54, 14, -51, -128, -115, -87, -55, -128, -43, -40, -24, -77, -38, -21, -18, -55, -75, -59, -86, -107, -89, 26, 13, -1, 9, 14, -43, -81, -12, 33, -81, -125, 2, -50, 66, 10, -34, -27, -128, -43, -14, 38, -45, -9, -4, -31, -89, -128, -128, -108, 49, -103, -118, -55, -45, -39, -94, 7, 84, -29, 13, 41, -20, -87, -6, -87, 122, -116, -67, -106, -21, -98, -5, 36, 29, -43, -13, 27, 10, -39, -1, -6, 87, -97, 43, -128, -80, 38, -47, -43, 105, -63, 20, -12, -10, 4, -92, -121, 100, -19, -63, -39, -18, -87, -6, 1, 49, -14, -128, -47, -91, -124, 63, -99, -43, -89, 115, -87, -27, -94, -95, -91, 1, 26, -116, -6, -39, -46, -54, 34, 12, -97, 117, -93, -41, -67, -43, 72, 37, -80, -1, 3, 7, -84, -6, -70, 100, -41, -73, -80, 20, 46, -91, -37, 50, -8, -95, 14, -128, 6, -24, -100, 102, 4, 64, -111, -87, -9, -43, 21, -51, -116, -14, -46, -39, 13, -71, -23, -33, -99, -128, -59, -33, 3, -128, -86, 89, -71, -38, -91, -14, -103, -19, 7, -86, -62, 2, -101, 1, -87, -95, 7, 81, -91, -2, -21, -81, -71, -4, -85, -14, -113, 97, -62, 89, 14, -66, 3, -7, 1, -89, 1, -72, -110, -54, 9, -109, -74, 51, -41, -14, 9, -59, -55, 51, -16, -21, -13, -91, -38, -77, -92, -92, -54, -95, -5, 46, -87, -102, -67, -67, -38, -1, -64, -31, -38, -67, -63, -71, -8, 24, -121, 16, -128, -21, -19, -4, -54, -23, -54, -50, -48, -21, -47, -114, -28, -14, 47, 29, -89, -48, -55, 1, -124, -122, -49, -50, 1, -4, -9, 75, -38, -28, -48, -33, -4, -114, -59, -50, -49, -103, 28, -29, 29, -124, -36, -7, -64, -28, 27, 59, -40, -68, 40, 45, 37, -93, 70, 26, -67, -68, -6, -97, 16, -62, -40, 4, -59, -80, -9, 33, -23, -55, -29, -1, -98, 40, -71, -20, -31, 118, -59, -45, 36, -45, 12, -14, 1, -40, 73, -18, -77, -47, -87, -106, -86, 51, -67, 29, -24, -128, 9, 59, 24, -21, -13, -74, -67, -40, -13, -71, -59, -128, -94, -14, -43, -90, -24, 76, -86, 8, -3, -128, -23, -51, -16, -72, -47, 67, 4, -16, -47, -63, 41, 6, 14, -48, -13, -4, -43, -13, 26, -62, -66, 18, -20, -31, -43, -28, 54, -84, -95, -18, 8, -36, -107, -21, -45, 24, -38, 117, 51, -128, -86, -37, 1, -21, -49, -110, -54, -29, -54, -80, -23, 67, -2, -99, 7, -50, -31, -111, -128, 76, 12, -10, 74, 21, -110, -109, -40, -85, 28, 47, -86, 26, 18, -71, 62, 18, -7, -78, -10, 1, -21, 18, -71, -9, -76, 127, -29, 6, 3, -122, 28, 36, -38, -54, -18, 5, 4, -21, -47, -128, -77, 31, -128, -41, -67, -29, 54, -64, -13, -43, -39, -63, -51, -84, -101, -67, -73, 46, -59, -24, -8, -114, 8, 12, -46, 21, 49, -128, -24, -24, 18, -49, -128, 87, -66, -21, -72, -90, 43, 45, 28, -84, -29, -38, -48, -67, -92, 1, -128, 45, -74, -55, -73, -85, 9, -43, -59, -33, -1, -10, -38, -23, -106, 28, -122, 110, -13, -68, -54, -36, -6, -24, -31, 21, 38, 20, -43, -128, -23, -16, -20, -74, -37, 123, -51, -59, 16, 121, 6, -86, -99, -23, -128, 5, -49, -91, -128, 66, -54, 27, 49, -71, 73, 4, -109, -84, 67, -10, -59, -26, -54, -128, 23, 43, -97, 59, -85, -68, 14, 48, -46, -93, -73, -59, -1, -74, -86, -59, -67, 46, -128, 76, 18, -87, -59, 59, -27, -55, 21, -55, 24, -21, 5, -49, -68, 59, -128, 23, -110, -128, 48, 75, 1, -36, 45, -20, -64, -110, -28, -103, -75, 70, -40, 16, -7, -94, 41, 84, -93, -1, -6, -43, -9, -39, -14, 84, -14, 93, -128, 39, -93, -8, 24, -45, -121, -31, 34, -77, 38, -9, -31, 20, -31, 67, -3, -50, 46, -85, 43, 1, -71, -51, -26, -78, -75, -128, 46, -6, -99, 95, -38, -77, -106, -59, 92, 29, -87, -50, 93, 47, -59, -116, -43, -77, -128, 38, -115, -54, -87, -39, 48, 21, -26, -16, 46, -77, -27, -46, -93, -128, 13, 76, -55, 14, -38, -78, 90, 64, 3, -89, -21, -5, -71, -24, -111, 3, -23, 47, -71, -16, -13, -115, -51, 39, -128, -77, -24, -23, -51, -113, -75, -34, -38, 127, -99, -31, -14, -6, 21, 48, -103, -128, 21, -73, -51, -48, -80, -84, -75, 111, -62, 23, 6, -128, -26, -59, -128, 14, -40, -74, -92, 26, -36, 121, -74, 74, -13, 27, -8, -29, -18, 67, -63, -26, -4, -105, -12, -4, -62, 38, -67, 117, -87, -87, -38, -48, 54, 39, -21, -74, -39, -43, -14, -73, -10, -34, -18, 34, -85, 75, -128, 29, 40, -46, -128, -128, 45, 67, -90, -19, -47, -114, -73, 108, -59, -64, -87, -62, -4, 97, -71, -117, -89, -14, -97, 7, -78, -75, -73, -55, -127, 1, -85, 24, -43, 6, -89, -97, -50, -86, -85, -91, 10, -29, 33, -68, -67, -90, -51, -18, -1, 105, -117, -94, -63, -128, -106, 26, -97, -26, -21, -37, -59, 26, -84, -4, 1, 24, -54, -21, -14, -90, -84, -103, -21, -21, -9, -64, -2, 27, -21, -76, 34, 127, -31, -90, -24, -89, -91, -2, -19, -124, -124, -100, -87, 36, 29, -40, 46, 6, -115, -43, 47, -80, 3, -62, -33, -19, -28, 59, -38, 24, 19, -59, 78, -29, -41, -95, -7, -19, -77, -48, -92, 43, -89, -68, -102, 127, -67, -23, -87, -92, -103, -109, 64, 80, -31, 127, -51, -1, -62, -98, -128, 13, -73, -46, -36, -115, -55, -128, 68, 5, -128, 21, -66, -36, 26, -19, -14, 73, -16, 21, 36, 97, -76, -50, -6, -5, -128, 127, -70, -50, -113, -33, -7, 49, -18, 14, -9, 75, -13, -117, -1, -50, -33, 66, 8, 4, -75, -91, -66, 41, -37, -125, 85, 38, -76, -85, 37, -21, -49, 103, -24, -80, -72, -128, -41, -7, -102, -125, -70, 40, -87, -128, 43, -107, -24, -81, -10, -128, -128, -128, -54, -21, -64, 3, -55, -14, -95, -76, -34, -124, -63, 12, -19, -86, -40, -16, -45, -127, 2, -21, 19, 38, -116, -47, 7, -128, -9, -28, -59, 37, 7, 127, -128, -13, -110, -66, -34, -114, -84, -86, -49, 4, -76, 127, -125, 70, 39, -91, -49, -14, -102, -62, -46, -43, -31, 14, 108, -34, -128, 2, -55, 90, -128, -99, -105, 37, -40, -117, -91, -87, 31, 3, -24, -37, -105, 87, -67, -84, -72, -7, -26, 8, -121, -59, -29, 118, -9, -109, 66, -46, -48, 127, -95, -77, -40, -117, -50, 108, -113, 2, -87, 78, -19, -70, -20, -95, -36, 115, -47, -128, -38, -9, -49, -33, -29, -102, 86, 108, 41, -45, -21, -86, -128, 59, -36, -100, -39, -87, -92, 31, 10, -43, 14, 29, -71, -28, -106, -67, -89, 31, -37, -77, -98, -16, -34, 97, -123, -47, 21, 28, -14, 3, -74, -95, -41, -95, -97, -58, -5, 21, -53, 27, 102, -20, -70, -39, 89, -46, 11, 127, -123, -7, -99, -71, 4, -34, -123, 65, -43, -104, -46, -60, 84, -90, -57, 1, 42, 93, -13, -53, -49, -71, -127, -64, 35, -92, -106, 10, 9, 114, 45, -76, -9, 108, -128, -40, -30, -90, -103, -20, 28, -49, -61, -47, -128, -9, 64, -36, -42, -98, -53, -40, 14, -30, -112, -36, 75, -112, 5, -26, -52, 33, 53, -62, -110, 27, -49, -23, -58, -75, -35, 1, 35, -70, -92, -124, -54, 49, -44, -124, -71, -80, -41, -25, -60, 46, -64, -108, 70, -128, -86, -124, -18, -2, -42, -5, -68, -53, -128, -43, -81, -52, -23, -7, 47, -41, 9, -58, -81, -72, 7, -38, 9, -128, -50, -70, 10, 57, 91, 10, -49, -119, -52, -61, 118, -82, 71, -1, -100, -10, 5, -65, 5, 21, -14, 4, 18, -115, -86, 68, 70, -127, 4, -8, -128, -57, -113, -61, -36, -34, -43, -18, -27, -50, -5, -75, -64, 70, 41, -86, -72, 14, -57, -38, -34, -26, -1, 4, 5, 2, -36, -123, -68, 42, -26, -54, -94, 45, -111, -82, 61, 30, -109, 18, 81, -89, 100, -57, -20, 70, -40, -18, -14, -80, -68, -10, -128, -40, -60, -2, -38, -97, 16, -101, -2, 90, 15, -80, -106, 25, 105, -61, -76, 50, -52, -38, 33, -88, -9, -128, -66, -66, -83, -128, -66, -8, -47, -49, -104, -14, -113, 87, -52, -36, 43, -84, -120, 44, -4, -102, -128, 49, 58, -40, 2, -36, -21, 50, -22, -13, -15, 122, 14, -113, 127, -14, -19, -87, -128, -128, 64, -115, -128, -5, 100, -58, -111, 18, -88, -92, -18, 58, -77, 32, 5, -89, -21, 127, -43, -50, 23, -92, 57, -40, -128, 20, -27, 20, -2, 75, -108, -81, -14, 124, -114, -50, 112, -4, 4, -128, -92, 27, -15, -23, -128, 5, -9, -1, -13, 92, -128, -28, -98, -68, 1, -34, -2, 77, -38, -128, -110, -9, -43, 1, -53, 67, -65, 19, -39, -101, -82, -41, -115, 111, 44, -128, -53, 28, -97, -39, -23, -64, -61, -8, -43, -97, 18, -2, -66, -47, 18, -128, -117, -2, -21, -104, -28, -98, -68, 11, -53, -82, 19, 15, -39, -47, 11, -54, -62, -92, -76, 107, -41, -54, 15, 28, -49, -57, 39, 103, 42, -47, 127, 1, -128, 9, -82, -47, 15, -128, -53, -27, 93, -128, -110, -1, 84, -52, -1, 28, -43, -28, 18, -28, 47, 27, -92, -41, 73, -47, -128, 94, -76, -128, -8, -61, -35, -5, 4, -77, -4, 38, -84, 15, 5, -106, 22, -49, -75, -7, 10, -76, -84, 21, -31, -38, 47, 49, -32, -7, -7, -19, -66, 8, -31, -93, -26, -10, -128, -5, -46, 18, 11, 62, -109, 70, 47, -52, -46, -10, -77, -21, -89, -67, -47, -57, 14, -49, -47, 52, -105, -19, -39, 2, 62, 1, -52, 72, 46, -11, -30, 8, 53, -128, -43, -18, 8, -31, -71, 7, 2, -60, -70, -7, 34, -54, -49, -34, -62, 54, -83, 109, -64, -21, -61, -10, 43, -128, -100, -40, 86, 39, -91, -30, -123, -70, 68, -128, -76, 50, -85, -16, 34, 102, 102, -20, -14, 28, -100, -82, 39, -84, -74, -9, -28, -27, -62, -128, -31, 76, -101, 5, -9, -2, -21, -66, 35, -60, -66, -44, -5, 46, 66, -57, -39, 13, -118, -86, 58, -64, -128, 4, 20, -61, -8, -35, -114, -47, 104, -54, -52, 46, -60, -38, 26, -99, -128, -18, -88, -42, 38, -16, -53, -19, 127, -93, -46, -81, -67, -22, 23, -128, -52, 57, -7, -118, -39, 11, -85, 21, -72, -124, 34, 1, -71, 41, 11, -38, -72, 14, -2, -90, -84, 47, -41, -7, 9, -87, 11, 88, -50, 23, -2, -124, -83, 124, 36, 39, -4, -77, -115, -39, 15, -128, 38, -34, -103, -128, -57, 50, -77, -32, 5, 91, 2, 103, -47, -1, -85, -75, 10, -103, -19, -60, -5, 77, -67, 11, 53, 5, 16, -44, -73, -25, -117, -38, -30, -100, -77, -49, -41, -7, -120, -32, -47, -14, -47, -68, -128, 57, -70, -81, -35, 107, -77, -11, 23, -53, -32, 28, -7, -36, 8, -128, -65, -22, -90, -16, 58, 11, -67, -128, 16, -18, -33, 23, 54, -42, -50, -1, -23, -45, 1, -73, -45, 26, -128, 2, -16, -90, -73, -66, -47, -71, -47, 44, 10, 5, -49, -28, -2, 25, -120, 57, -47, -42, -57, -2, -13, -104, -86, 125, -9, 2, -57, -128, -1, -73, -89, -10, 64, -66, -82, 45, 60, -54, -47, -26, -50, 5, -70, -108, -31, -27, -28, -27, 46, 11, -11, 5, 58, -57, -76, -128, -9, -45, -90, -100, -54, -90, -84, -102, 7, 54, -104, 47, 83, -105, 28, 8, -64, 7, -92, -62, 4, -43, -119, -50, 23, 13, -22, 16, -87, -110, 80, -91, -45, 43, -90, -28, 30, -72, -21, -64, 23, -28, -85, -2, 54, -25, -19, -5, 14, 11, -104, -30, 5, -23, -46, -122, -1, -115, -113, -11, -7, -86, 110, -42, -38, 28, -41, -49, 31, -5, 107, -47, 33, -30, -34, -4, 5, -77, -124, 8, -75, 4, -10, -128, 2, -21, -73, -128, -32, -26, -83, -47, -35, -117, -21, -14, -40, -32, -99, -36, 2, -14, -11, -53, 13, -57, -9, 42, 23, 1, -64, -53, -92, -62, -123, -62, -27, -93, -16, -92, -93, -20, -89, -71, 26, -53, -8, -97, -89, -11, -19, -81, 23, -81, -93, -117, -73, -47, -89, -81, -67, -67, -15, -53, -128, -71, -99, -84, 41, -61, -15, -13, 22, -38, -23, -39, 62, -124, -35, -80, -87, 67, -75, -101, -53, -5, -39, -47, 82, -5, -108, -14, 18, -47, 28, -35, -80, -16, -54, -47, 30, 14, -23, -2, 53, 23, -22, 4, 40, -44, -18, -73, -90, -54, -103, -82, -54, -47, -28, -126, -4, -105, -114, 5, 25, -80, 46, -85, -19, 28, -111, -111, -77, -22, -112, -34, 23, -81, -14, -16, 85, -16, -107, 1, 21, 41, -52, -38, 38, 15, -109, -33, 31, -73, -114, -71, -114, -61, -18, -128, -4, -18, -99, -84, 89, -110, -123, -68, -72, 45, -103, -23, 68, 90, 35, -82, -70, 49, -89, -8, -43, -70, -94, -68, 14, -50, 8, 49, -15, 81, 87, -8, -102, -76, -71, -128, -5, -50, -21, -35, 14, 23, -58, -66, 14, -11, -39, 11, -81, 47, -7, -57, 1, -36, -47, -61, -57, -38, -128, 46, -16, 111, 40, -53, 5, -75, -43, -58, -38, -112, -98, -76, 41, 85, -40, -9, 11, -5, 39, -109, -15, -40, -67, -18, -22, 14, -128, -86, 7, 82, -60, -28, -16, -50, 127, 10, -14, 30, -114, -36, -21, -53, -33, -86, 26, -31, -76, 20, -90, -128, -38, -87, -50, -57, -71, -128, 11, -50, 21, -70, 1, -30, -89, -40, 20, 19, -15, -31, -41, -99, -58, -106, 62, -101, -36, -11, 15, -39, -85, -58, -113, -50, 7, -108, 1, 21, -30, -74, -52, -128, -83, -103, -43, -49, -124, 50, -5, 43, -81, -26, -67, -13, -7, -86, -10, -57, -115, -106, 26, 33, -77, -18, -34, -128, 83, -42, -68, 2, -113, 21, 10, -54, -92, -26, -2, -128, -93, -67, 57, 67, 7, -39, -15, -64, -70, -81, 40, -27, -31, -11, 2, 19, -11, 18, 52, -73, 45, -125, -84, 5, -74, -8, 31, -118, -68, -14, -9, 11, -107, -26, -58, -34, -127, -36, -128, -40, -52, 127, 5, 90, -41, -33, 43, -11, -30, -61, -14, -128, -52, -30, -62, 21, 10, -44, 36, 73, 43, -23, -9, -75, -18, -16, -2, 5, -67, -10, -72, -27, -10, -74, 20, -53, -71, -114, -91, -50, -66, 23, -75, -117, -57, -61, 5, 13, -35, -73, 40, -52, -11, -83, 107, -4, -118, 13, -2, -98, -42, -65, -70, -39, -88, -9, 39, -113, -18, -91, -98, 11, -112, 127, -47, -101, -50, -71, -40, 5, -72, -43, -22, -102, -64, -81, 76, 35, -2, -31, -18, -88, -40, -39, -82, -88, -42, -47, -28, -23, -30, -111, -21, 127, -15, 14, -15, -44, 11, -27, -120, 33, -107, 72, 45, -106, -128, -31, -33, 52, -23, -61, -32, -33, -45, -41, -81, 7, -72, -10, -5, 127, 100, -82, 120, -1, -111, 60, -25, -104, -86, -34, -28, -34, -71, -112, -1, 49, 46, -31, -47, -99, -124, -111, 62, -70, -128, 65, -72, -114, -46, -125, -20, 9, -88, -77, -128, -1, -25, 40, -117, -5, -119, -2, -110, -33, -46, 28, 30, -44, -60, -122, -62, 41, -47, -70, -8, -49, -94, -54, -92, 1, -99, -9, -36, -62, 87, -61, -46, 87, -89, 38, 23, -50, -74, -45, -100, -16, -64, -65, -15, -47, -54, -92, 7, 65, -58, 31, 50, 27, -128, -2, -84, -77, -4, 4, 77, -68, -76, 5, 35, -11, -61, 23, -72, 97, 94, -36, -104, 71, -50, -8, -22, 7, -85, -66, -25, 27, -10, 45, -13, -89, 27, -105, -84, -27, -49, 4, 9, -60, 33, -128, -68, -91, -128, 68, 2, -47, -35, -15, -71, 38, -70, -74, -19, -44, 76, -65, -104, -66, 20, -125, -1, -104, 46, 85, -39, 19, 34, -32, -128, -24, -128, -128, 3, 69, -110, 109, -74, 3, -37, 19, 9, 2, 24, -91, -15, 79, 107, -97, 18, -102, 15, 4, 79, -2, 7, 56, -18, 86, -6, -95, 15, -4, -128, 30, -76, -100, -74, -43, 8, -51, 59, -90, -105, 9, -62, -67, -14, 12, -23, 88, -23, -122, -93, 6, -73, -128, 33, -14, 16, -1, -15, -103, 123, -55, -128, 78, -45, -56, 84, -19, -52, -128, -32, -44, -73, -82, -88, -93, 31, 21, -46, -95, -21, -103, -46, 3, 127, -58, -82, 30, -68, 87, 25, -95, -67, -30, -11, 68, -4, -121, 52, -128, -64, -119, -108, 67, -128, -114, -46, -43, -61, -38, -52, 51, 31, -97, -93, -15, -128, 78, 30, 73, -68, 59, -48, -14, -111, 39, 9, -91, 43, 7, -14, -46, -67, -46, -69, 6, -93, -56, -9, -46, -38, 34, 7, -101, 3, -33, -82, -23, -67, -78, -12, -58, -73, 51, -3, -59, -78, -9, -22, 25, -11, 87, -18, 19, 14, -114, -4, -49, -4, -39, 43, -14, 13, -89, -53, 89, -9, -19, -61, 15, -128, -27, 2, -39, -52, 49, -6, -125, 3, -71, -91, 114, -49, -128, 109, -4, 64, 6, -27, 30, -62, 9, -19, -18, 30, -1, -64, 105, 62, -105, -39, 73, 38, -127, 98, -31, -11, -4, 25, -73, -47, -82, -100, 19, 2, 4, 78, 1, -38, -114, -47, -8, -4, 73, 74, -42, 14, 119, -87, 16, -25, -68, -43, 19, 33, -109, -51, -90, 59, 3, -7, -61, -100, 79, 68, -61, 123, -38, -42, -11, -51, -44, 69, 79, -108, 16, -16, -101, -31, 52, 12, -36, -38, 15, -84, 31, 73, -37, -26, -51, -76, -68, 89, -90, 23, 102, 4, 15, 16, -74, -48, 19, -31, -128, -2, 9, -39, 9, -34, -56, 3, -52, -82, -1, -11, -38, -62, 31, 16, 14, 2, 30, -100, -46, -36, -117, 79, 1, -86, 53, -53, 67, -34, 68, -16, -53, 2, -79, -26, -2, -19, -93, 45, -23, 77, -13, 1, -128, -47, 11, -42, -86, -98, -79, -102, 14, -15, -128, -12, 6, 90, 94, 1, -118, -118, 51, 49, -128, -55, -51, -39, 1, -71, -39, 24, 28, 61, -39, -19, -79, -74, 26, -72, 117, 71, -39, 39, -14, -81, -106, 39, 125, 76, -98, 16, -48, -85, 3, 59, -128, 4, -12, -55, 62, 127, -128, 82, 24, -64, -13, 67, 9, -91, 28, 71, -90, 11, -126, -112, 8, -84, -103, 30, 122, -117, -31, -68, 78, -52, 58, -49, -71, -4, -62, -77, -8, 105, -34, 32, -4, 79, -51, -26, -18, 2, 44, -69, -108, 43, -101, -79, 19, 82, 14, 52, -11, -77, -72, -36, -22, -122, -64, -47, -101, -19, 51, -59, -79, -84, -88, 3, -56, -64, 107, -15, -44, -87, 34, 14, -39, -93, 23, -128, -81, -81, -126, -22, 51, -102, -13, 38, -37, -100, -19, 1, -101, -73, 89, -122, 8, -59, -78, -7, -3, -74, 42, -73, -87, -106, -14, 53, 31, 53, -9, -107, -45, 126, 39, 76, 51, -24, -67, -18, 26, -87, -24, 1, -18, -21, -9, -55, 12, 8, 64, 88, -120, 45, -67, -46, -24, -55, -39, -6, -48, 58, 22, -114, 8, 110, -71, 76, -11, 73, -100, -4, -24, -87, 34, -43, -103, 4, 59, -47, 22, 127, -93, -27, -37, -27, -120, -4, -55, -36, -22, 37, -3, 11, -73, -110, 38, 127, -46, 11, -30, -82, -121, 37, -64, -86, -26, -84, -118, -48, -13, -117, 55, 56, -3, -27, 64, -128, 127, -46, -77, 16, -11, 45, -90, -42, -76, -89, -1, 108, -8, -27, -31, -76, -32, -21, -128, -16, 55, 67, 23, -116, 36, -79, -46, 101, -78, 42, 7, -12, 34, 15, -26, -51, 32, -58, 90, 44, 23, -116, 53, 62, -74, 61, 32, 55, -109, 86, 21, -63, -22, 114, 1, 13, 9, -82, 51, -23, 62, -8, -34, 39, -81, -67, 55, -107, 7, 77, 98, 7, 43, -128, -19, 63, 86, -85, -51, -61, -102, 27, -1, -119, -49, 6, -95, -55, 85, -94, 72, 64, -79, -37, -11, 13, -31, -3, -6, -128, -7, -59, -44, 46, -116, -1, -79, 51, -49, 25, -19, -37, -28, -26, -90, -52, -9, -49, -16, 46, -34, -111, -62, -9, -120, 18, 74, -79, -1, 18, -45, -14, -1, 9, -72, -84, 48, -110, 14, 81, -44, -19, -64, -37, 121, 46, 11, -71, -12, -1, -85, -9, 119, -120, -22, 84, -109, 36, 27, -110, -38, -34, -68, -46, 71, -49, -11, -4, -30, -114, 11, -114, -128, 61, -79, 18, 13, 127, 47, -72, -43, 122, 36, 56, 67, -9, -21, -104, 87, 2, -16, -128, -30, 2, -18, -11, -1, 89, 111, -62, 56, -25, 30, -33, 32, 42, -13, 30, 124, -19, 4, -27, 23, 16, -76, 51, -13, 1, 30, -84, -128, 14, -11, -52, -124, -21, -13, -68, 56, -51, -64, -4, -12, -85, -43, -79, -68, -79, -55, -71, -91, 19, 90, 2, -1, -13, -102, -7, -62, -128, -64, -68, -13, -9, -45, 15, -100, -31, -106, -89, -7, -8, -55, -128, 111, -79, -77, -118, -114, 1, -34, -105, -112, 19, -128, -30, 1, -27, -37, -36, -84, -31, 56, 9, -128, 7, 21, -59, 26, 47, -128, -76, -14, -7, -16, 82, -84, -67, -59, -112, 1, 67, -77, 104, -34, 73, 13, -9, 73, 82, -11, -89, -128, -118, 47, -18, -119, -33, 42, -98, -55, 16, -46, -114, 19, 45, 19, 2, -114, -42, -1, -52, -7, 2, -3, -88, -39, 23, 39, -32, -2, 4, -8, 18, -100, -9, -7, -31, -124, -19, 9, -84, -67, -28, -67, -14, 71, 43, 6, 2, -128, -100, 53, -127, -2, -15, 2, 36, 44, -47, 106, -38, -79, 3, -118, 39, -9, -47, 19, -73, -85, -7, 43, 127, -76, 87, -77, -106, 1, -27, -102, 19, 97, -68, 39, -68, -128, 44, -38, 118, -19, -14, -82, -68, 51, -38, -123, 19, 7, -55, -16, 44, -108, 19, -33, 7, -125, 12, -43, -94, 14, -1, 30, 6, -78, -28, -47, -101, -21, -37, -128, 14, -45, 34, -22, -39, -53, -69, -27, 46, 22, -108, 3, -1, -44, -38, 27, -84, -46, -64, 37, -106, -26, -12, 111, 9, 98, 15, -1, -67, -128, 34, -67, -16, -114, -30, -72, -12, 26, 64, -39, 39, 74, -128, -22, 6, -89, 2, -122, 46, -128, -9, 4, 15, -78, -13, -86, -28, 19, -90, 9, -52, -93, -3, -4, 8, -44, 13, 118, -109, -27, -59, 120, -22, -110, -39, 91, -33, -42, 19, 71, 122, -103, -71, 76, 18, 26, 13, -78, 62, -42, -48, -37, -82, -49, 33, -39, 127, -71, 2, -21, -128, 69, 42, -22, -123, -128, -108, 62, 103, -100, 62, -48, 4, 22, -69, -51, -30, -128, 23, -1, -13, -61, -128, 49, -112, 9, -58, -52, -107, -128, -87, -11, -39, -6, 82, -128, 62, 73, -101, -45, -128, -103, 25, -128, -118, -79, 19, 16, -71, 47, -7, 73, -38, -109, -36, 61, -43, 4, 23, -122, 9, 51, -8, -16, -39, -7, 39, 76, -15, -128, -56, -61, -44, -61, -39, -15, -72, -106, -11, -72, -53, 6, -4, -88, -11, -38, -69, -22, -103, -109, 27, -21, -128, 59, -49, 78, -37, 23, -22, -128, -49, -8, -106, 14, -79, -21, -24, 88, 64, -122, -52, 89, -51, 28, 18, 9, 87, -118, -59, 91, 6, 88, -4, 1, 19, -52, -21, -67, -38, -73, 43, -85, -88, -109, -94, 24, -42, -128, 15, 73, 7, 55, 67, -114, -128, 9, -7, -19, 98, 1, -128, 82, -97, 49, 22, -85, -52, -26, -76, 19, -79, -9, 32, -4, -30, -21, -44, 86, -1, -38, -15, -53, -28, -14, -16, 49, -111, 14, -27, -42, -19, -123, -58, 85, -98, -1, 19, -78, -62, -121, 25, 51, -77, 33, -22, -30, 43, -53, -18, 28, -67, -39, -30, -105, -1, -84, 61, -39, -74, 64, 4, 127, 12, -72, -39, -52, -19, 7, 79, -7, -106, -128, 34, 127, -51, 24, -68, -38, 117, -74, -88, -18, -42, 31, -19, -21, 127, -111, 7, 127, -125, -31, 1, -56, -4, -63, -15, 13, -94, 14, -15, 8, 105, -39, -18, -52, 15, 74, -2, -9, -82, -32, -61, -45, -93, -105, -6, 89, -109, -128, -81, -119, -128, 110, -30, 43, -39, -25, -116, -81, -128, 98, 25, -49, -27, -111, -126, -19, 19, 34, 31, 9, 72, -36, -101, -21, -107, 47, 19, -97, -121, -34, 34, -47, -89, 11, 24, -88, -34, -69, -51, -31, -97, -13, 42, -28, -117, -49, -1, -15, -19, 22, -63, -93, 28, -59, -124, 3, -2, -62, -51, -128, -18, -79, -58, 9, 19, -9, -4, 100, -11, 3, -25, -24, -81, 16, 18, -127, -53, -74, -88, 38, -62, 2, -21, 48, -56, -27, -39, 1, -58, 79, -84, -86, -107, 11, -24, 95, -18, -18, 13, -88, 63, -123, -72, 45, -1, 87, 2, -95, 74, -58, -15, 51, -24, -38, 82, -39, 26, 11, -88, 31, -128, -38, 24, -12, 127, -82, 108, -47, -61, 79, -54, 127, -7, -14, -106, 60, -29, -83, 93, 42, -54, -20, -119, -71, -36, -17, -40, 93, -2, -2, -42, 78, -89, -39, 127, -23, -72, -15, 102, -56, 25, -35, -67, 38, -63, -46, -67, 92, -101, -5, 100, 56, -98, -88, -40, -85, -92, -45, -2, 72, -127, -42, -128, 88, -9, -83, -40, -113, -19, -70, 1, -80, -43, -128, -38, -17, -97, -9, -89, 2, -39, -35, -99, 7, 8, -95, -8, -113, -100, -128, -95, 10, -42, 15, -21, -31, -35, -32, -21, -18, -73, -97, -29, -52, -27, -71, -11, 57, -59, -8, -85, 67, -102, -89, -99, -15, -52, -65, -45, -113, -73, -128, -30, -71, -47, 5, -65, 11, -35, -128, 33, 2, -73, -15, -79, -11, -114, -128, -95, 72, -83, 4, -99, -62, -121, -5, 98, 124, -57, -114, 5, -4, -86, -92, -53, 35, -18, 97, -65, 2, -4, 8, 54, 98, -79, -45, 5, -126, 2, -49, -52, 37, -87, 29, 30, 62, 9, 2, 83, 21, -73, -70, 15, -19, -92, -125, -26, -18, -45, -27, -17, -9, -89, -98, -59, -89, -59, -72, 20, -78, -11, -126, -53, 36, -116, 26, -128, -23, -37, -93, -128, -86, -73, -128, 23, -97, 16, -37, -126, -95, -66, 90, -2, 14, -105, -5, 1, 2, -88, -119, 72, -128, -14, 9, -100, 70, -92, 29, -89, 63, 2, -60, 43, -32, -72, -94, -40, -80, -21, -46, -95, -121, -49, 83, -11, -95, -43, -67, 38, -128, -39, -93, -36, -65, -72, -49, -52, 23, -19, 127, -91, -74, -35, 4, 106, 45, -94, -54, 82, -27, -9, -57, -80, 49, -23, 47, -84, -18, -31, -128, 86, 66, -119, 2, 4, 56, -49, -84, -32, 112, -128, -66, 2, -7, -128, -90, 39, 43, -114, -52, 25, -5, -21, -72, -7, -88, -40, -109, -1, 40, -85, -59, 2, 113, -31, -118, 11, -56, -38, 5, -65, 72, -59, -86, -67, -54, -128, -36, 39, -23, -5, -128, 10, -119, -79, -93, -95, 65, -120, -60, 14, 26, -10, -43, 30, -35, -32, -90, -23, -128, -19, -10, -71, 60, 46, -66, -15, -35, -115, -86, 10, -72, -125, -40, 14, -2, 20, -71, -20, -73, -66, -84, -59, -101, -2, -82, -47, -10, -33, -11, 27, -63, -27, -57, -9, 89, -128, -54, 11, -17, -47, -38, 9, -128, -42, -47, 127, 26, -2, -63, -59, 31, -16, 95, -128, -65, -122, -7, 33, -27, -74, -67, 5, -30, 11, -8, -30, 66, -23, -53, -77, 29, -84, -18, 50, 37, -114, -56, -2, -78, -15, -128, -37, 127, -107, -16, -30, -46, -42, -49, 53, 33, 26, -84, 2, -74, -14, -105, -124, 57, -128, -115, -23, 14, -11, -5, 21, -40, -97, -98, 23, -40, -101, -47, -77, -128, -46, -100, -62, -5, -82, -125, -27, 8, -65, -128, 29, -108, 23, -37, -128, 67, -35, -85, -94, 35, -88, -106, 25, 37, -115, -39, -1, -102, -56, 4, -66, -78, -14, -128, -47, -67, 19, -39, -84, -8, -59, -42, 47, 4, -1, -128, -33, 93, -8, 17, -47, 31, -107, -85, 38, 35, -60, -95, -94, -53, 16, -31, -107, 49, -128, -2, 21, 50, -63, -95, -127, -89, -46, -115, -11, 60, 33, 127, -80, 85, -74, 91, 11, -11, -128, 10, -70, -31, -83, -66, 42, 18, -11, -57, -7, -128, -39, 118, -66, -67, -77, -11, -36, -20, -27, -82, 19, -42, -39, 1, -122, -127, 5, -26, -30, -46, -109, -63, -26, 29, 23, -86, -47, -128, -31, -2, -35, -102, -35, -62, -16, 66, -90, -98, 32, 5, -102, -114, 42, -128, 1, 2, -114, 1, -18, -5, -62, 83, -33, -23, 49, 85, -49, -88, 15, -128, -32, -128, -128, 106, -87, -23, -80, 5, -26, -79, -49, -18, -89, -91, -5, -57, -84, -93, -93, 127, -63, 86, -83, 83, -40, -11, 45, -109, -66, 23, -1, -27, -120, 11, -83, 127, -14, 122, -2, 1, -23, -35, -47, -28, -63, -50, 73, 35, -90, -1, -43, 88, -90, 77, -57, 11, -39, -112, -5, 102, -108, -86, -11, -128, -78, -95, -17, -56, -99, 8, 4, -49, -50, -110, 83, -100, -9, -23, 47, -62, -90, -30, -86, -7, -53, -60, -98, 2, -40, -102, -35, 42, -74, -98, 26, -108, -54, -52, -57, -65, 25, 16, -29, 45, -38, -82, -33, 10, -86, -45, -21, -93, -43, -57, -84, -60, -40, 27, -9, 37, -95, -53, -11, -27, -60, -56, 5, -85, -110, -27, -20, 108, -100, -108, -72, -71, -18, -93, 2, -7, -128, -82, -17, 2, -102, -30, -36, 1, -71, -122, -63, -9, -65, -122, 109, 92, -66, 2, 60, 14, -77, -95, -42, 87, -97, 62, -4, 39, -105, -30, 62, -87, -16, -52, -11, 37, -21, -16, -90, 85, -70, 46, -39, -38, -114, -102, -56, -47, -95, 21, -26, -57, -78, -107, -1, -128, -101, 92, -25, 27, -66, -63, -10, 11, -87, -29, -17, -94, 7, 19, -7, 49, -128, 88, -4, -25, -92, 7, 45, 35, -124, -72, 1, -38, -73, -14, -92, 60, -86, 110, -85, 1, -125, -73, 23, 26, -9, -95, -53, -26, -25, 31, -71, 7, -128, 85, 32, 74, -59, -30, -71, -26, -1, -71, -28, -32, -17, -33, -53, 90, -101, 127, -71, 11, -47, -94, 79, -18, -14, 19, -7, -87, -27, -1, -128, -63, -56, -78, -88, 86, -114, -73, -1, 45, -32, -66, 79, 32, -5, -15, -73, 90, -56, 97, 21, -31, -95, -32, 37, 49, 11, -45, 8, 62, -77, -26, -128, 109, -105, 18, -66, -7, 1, -27, 80, -16, -47, -74, -63, 2, 23, -86, -74, 79, -23, 36, -17, 11, -28, -127, -2, 40, -20, -39, 5, -66, -26, -26, -67, 82, -9, 101, -50, -38, 16, -83, 4, -30, -83, -23, -40, -57, -11, -78, -46, 14, -10, 89, -128, 21, -74, -38, -11, -2, -59, -128, 62, -77, -53, -7, -71, 95, -53, 23, -70, 67, -109, -83, 47, -7, -73, -128, -4, -17, -67, -100, -52, 38, -78, 102, -128, -71, -95, -95, -7, -7, -53, 25, 11, -120, -85, -11, -73, 1, -60, -102, -128, 66, -1, -42, 80, 31, -70, -63, -113, 23, -2, -27, -83, -30, -23, 127, -100, -27, -53, -92, 59, 127, -74, -2, 26, 5, 43, -74, -47, 95, -128, 43, -42, 73, -105, -128, -18, 47, -59, -80, -25, -115, -72, -2, -47, -119, -49, 57, -11, -82, -32, -105, 53, 66, -128, -14, -49, -27, 45, -83, -71, 33, -128, 17, -16, -80, -39, -121, -11, 74, -105, -63, 65, -40, -14, -54, -10, 18, -46, 91, -5, 19, -99, -43, -15, 47, 9, -30, -42, -124, -88, -91, -83, 33, -112, 2, -99, -1, -128, -122, -42, 5, -28, -94, -2, -74, -91, -17, -73, 30, 11, -128, -94, -1, -122, -23, 11, 38, -93, -17, 50, -19, -40, -23, -60, 11, -10, 30, 21, 67, -28, 5, -15, 70, -29, -79, 88, 11, -17, -106, -99, -29, -106, 57, 19, -5, -46, -77, -1, 115, -52, -46, -30, 72, -106, -73, -70, 2, 1, 67, -50, -21, -128, 7, 45, 127, -85, -106, 11, -10, -7, -57, -32, 79, -47, -47, -8, 31, -53, 23, -1, 113, -128, -62, -5, -50, -14, -17, -47, -116, -19, -26, -105, -23, -112, -70, -52, 127, -72, -49, -2, -57, -91, -31, -95, -47, -40, 101, -63, -42, -78, -74, 17, -60, -36, -47, 66, -80, -67, -128, -100, -49, -38, -16, -92, 31, -120, -11, -9, 29, -84, -2, 46, -33, 23, -60, -30, -26, -60, -37, -2, 50, -83, -57, -1, -87, -112, -72, 14, -102, -128, -90, -90, -85, 11, -11, -59, 72, -94, -56, -37, 127, -54, -38, 56, 42, -17, -47, -79, 120, -86, 80, 1, 18, -85, -19, -43, 63, -128, -23, 95, 4, -4, -115, -36, -26, -108, 54, -83, 102, -43, -33, 9, -83, -52, -77, 114, -47, -53, -53, -37, 126, -108, 127, -98, 5, -63, -54, 8, -40, -89, -60, -73, -25, -91, -88, -77, 20, -62, 23, 7, 84, -63, -19, 27, -110, -102, -38, 78, -56, -56, -31, -65, 43, -70, 8, -19, 74, -83, -38, 38, -62, -71, -30, -128, -11, 5, 93, -23, 127, -39, -54, -98, -9, -1, -77, 38, -92, -11, -27, 28, -128, -39, 101, -116, 45, -83, -33, -49, 127, -60, -72, -8, -28, -126, -9, 105, -66, -32, -63, -42, -47, -50, 83, 1, -85, -98, -1, 17, 21, -85, 5, -2, 79, 56, -45, -27, -33, -95, 79, -46, -10, -117, -36, -35, 17, -57, -26, 63, -25, -8, -5, -108, -82, -86, 11, -42, 67, 17, -98, 10, -100, -78, -25, -37, -128, -79, -128, 2, 84, -2, 26, -35, -14, 5, -88, -40, -90, -99, -80, -15, -102, -65, -47, -16, 127, -128, 127, -74, 95, -95, -93, -21, -88, -35, -92, 78, -99, -17, 19, -116, 43, -99, 99, -66, 2, -126, -86, 67, -78, -10, -91, -4, -118, -83, 126, -50, -99, -128, 32, 1, 29, 5, -60, 5, 107, -125, -60, 72, -59, -62, 36, -93, 54, -71, 109, -128, -79, -16, -25, -52, -50, -94, -52, 124, -105, -118, -54, 41, 12, -26, -1, 21, -7, -30, -3, 22, 65, 41, -21, -42, -7, 5, 24, 45, 3, -61, -11, 18, -25, -66, 58, 5, 70, 10, -45, 18, 61, -30, 26, 30, 25, 9, 1, 10, -19, -1, 36, 2, 107, 35, -42, 53, 44, 9, 32, 36, -5, 84, 11, 32, -10, -18, 55, -3, 97, 41, -21, -14, 45, 2, 10, 19, 15, 74, -35, 19, -3, -1, 5, 3, 91, 35, -24, -2, 45, 14, 32, 29, 19, 64, -36, -3, -7, -41, 26, -12, 58, 29, -35, 5, 21, 14, 30, 26, 21, 53, -53, 32, 26, -30, -2, -21, 91, 29, 24, -12, 9, 18, 24, 21, -15, 96, 1, 30, 15, -26, 10, 9, 65, 37, 52, -3, 21, 2, 11, 19, 1, 30, -15, -1, 1, -12, 7, 18, 52, 35, 2, 127, 3, 29, -3, 42, 30, 21, -11, 3, -30, 11, 52, 26, 24, 41, 3, 65, -5, 26, -65, 30, -1, 58, -10, 7, -30, -1, 75, 24, 32, 29, -7, 26, 19, 21, -37, 18, -1, 37, -66, 2, -7, -11, 32, -25, 47, 11, 55, 22, 25, 12, 26, 1, 14, 74, -82, -18, 15, 36, 1, -21, 26, 37, 47, -10, 9, 9, 5, 19, 29, 87, -82, 24, 45, 5, -2, -2, 47, 52, 18, -18, 22, -1, 45, -2, 19, 100, 12, 22, 36, -5, 3, -11, -25, 25, 26, -19, 25, -3, 18, -7, 21, 90, 12, 19, -1, -32, 11, -2, -75, 7, 64, 18, 29, 15, 18, 9, -21, 76, 3, 88, 22, 47, 14, 9, 35, 9, 29, 91, -37, 21, -45, 1, 32, 99, -10, 90, 15, 64, 53, 21, 30, 42, 30, 104, -87, 12, -77, 5, 18, 66, -76, 76, 58, 77, 5, 1, 15, 47, -35, 64, -10, 35, -110, 1, 14, 55, -10, 80, 76, 91, 32, -2, 25, 2, 42, 65, -15, 14, 10, 5, 12, 35, 18, 1, 7, 74, 10, -2, 64, 14, 104, 47, -21, 35, 36, -14, 3, 2, -1, 52, 30, 36, 26, 5, 107, 19, 120, 22, 29, 25, 61, 1, 12, 65, 14, -5, 3, 14, -14, -19, 99, 11, 52, -12, 15, 14, 9, 7, 22, 44, 11, -15, 37, -24, -2, 30, 122, -30, 30, 61, 18, 30, 25, 19, 24, 42, -12, 41, 53, -15, 61, 19, -53, -41, 21, -9, -55, -2, -15, 9, 14, 91, -10, 35, 76, 44, 65, -12, -102, 14, -9, 44, -122, 35, -36, 7, 19, 90, 15, 25, 59, 86, 26, -3, -89, -2, -30, 52, 9, 25, -41, -14, 19, 91, 47, 1, 74, 102, 30, 7, -74, -41, -22, 84, 15, 30, -14, -12, 15, 30, -53, -11, 41, 86, 12, -1, -42, -19, -84, 47, 2, 30, 30, -14, 22, -12, 3, -18, 21, 61, 7, 15, -52, -1, 32, 24, 12, 1, 52, -15, 14, 7, 42, -7, 5, 15, -3, -5, 87, 10, 59, -19, 15, 14, 30, -1, 5, 47, -25, 22, 1, 2, -5, 24, 26, -2, 59, -53, 11, 15, 10, 30, -1, -127, -19, 30, -1, -77, 32, 18, -113, -15, 64, -15, -41, 18, -80, 21, 25, -122, -9, 53, 36, -55, 26, 24, -80, -77, -10, -64, -26, 18, -45, 5, 1, -128, -1, 30, 41, -41, 66, 1, -61, 3, -89, 21, 7, 12, -19, -2, 2, 1, 44, 26, 61, 41, 53, -1, -10, -76, -122, 37, 90, 30, 58, -26, 9, 15, -12, 26, 2, 61, 32, -2, 22, -74, -96, 41, 24, 29, 11, -5, 25, 12, -42, -5, 25, 30, -11, 1, 89, -12, -86, 30, 10, -3, 44, -15, -1, 19, -21, -9, -15, 22, -11, -7, -36, -14, 24, 18, 2, 19, 30, 1, 26, 80, 18, -5, -3, 12, -10, 14, 10, -22, 64, -15, 9, 1, -1, 42, 21, -128, 32, -107, -19, -128, -15, 22, -25, 14, 121, -32, -24, 36, -84, 52, 2, -128, 76, -3, -26, -104, 61, -2, -84, -30, 55, -42, -41, 2, -87, 25, -1, -120, 84, 10, -12, -90, 41, 12, -55, 30, -128, -58, 55, 22, 1, 18, 1, -61, 37, 42, 15, -22, 90, 22, 52, -7, -128, 2, 58, 35, 84, -1, 15, -22, 55, 19, 9, -18, 87, -5, 19, 14, -90, 15, 35, 26, 61, -18, 11, 26, -18, 12, 5, 9, 35, 5, -12, -11, -91, 30, 37, 21, 77, -1, 3, 45, 19, 10, -19, 44, -9, -7, -53, -7, -12, -2, -36, 19, 30, -29, 25, 64, 21, 14, -12, 9, -25, 10, 24, -11, 36, -82, -1, -5, 11, 11, 7, -127, -127, -128, -84, -128, -99, -2, -75, 84, 127, -75, 32, 30, -36, 58, 2, -128, -128, -61, -44, -107, 11, -18, -101, 55, 115, -53, 90, 25, -42, 22, 42, -97, -80, -9, -32, -84, 9, 9, -107, 84, 37, -22, 114, 10, 14, 7, 19, -37, -9, 30, 22, -75, 66, -1, -52, 89, -110, -42, 89, 12, 59, 5, 19, -3, 30, -1, 1, -35, 99, 3, -70, 37, -96, 2, 55, 5, 35, 1, 12, -11, 36, 18, 15, -10, 47, 2, -55, 36, -41, -26, 1, 3, 58, 2, 14, 41, 29, 1, -15, -19, 1, -9, -2, -24, -7, -123, -29, 30, 58, -12, 12, 58, 18, 9, -2, 2, -2, 9, 58, -2, 19, -128, -12, 15, -5, 3, 2, 14, -128, -61, -25, -12, -128, -22, -52, 97, 127, -37, -5, 35, -128, 30, 18, -53, -119, -75, -5, -35, -30, 7, -107, 63, 127, -77, 25, 19, -70, -1, 18, -1, -76, -77, -44, -82, -61, -1, -75, 121, 127, -101, 101, 14, -59, 14, 5, 18, 10, -9, 12, -75, 12, -3, -120, 107, 77, -59, 70, 19, 26, 7, 9, 14, 5, -9, -3, -37, 45, 15, -120, 61, -36, 7, 76, 21, 30, -1, 3, 29, -2, -3, 21, -22, 32, 5, -114, 9, 1, 11, 36, 21, 65, 7, 36, -9, 18, 5, -29, -21, -1, 7, -24, 2, -61, 2, -5, 18, 12, -24, 22, 7, -1, 14, 15, -63, -14, -21, -96, -18, 22, -118, -1, 22, 5, -7, -9, 63, -84, 42, 25, 127, -84, -12, -11, 82, 127, 97, -107, 19, -128, 35, -19, -30, -70, 32, 10, 100, -26, -15, -30, 58, 127, 15, -45, 29, -128, -3, 15, -11, -52, -7, 7, 74, -65, 2, -106, 107, 120, -58, 99, 37, -76, -11, 36, 35, -42, 1, 88, -74, -2, -3, -110, 77, 42, -70, 127, 22, 9, 9, 15, -36, -37, -25, 42, -22, 10, 10, -41, 53, -7, -30, 127, 22, 65, -3, 7, -9, 25, 1, 26, -21, 30, -5, -7, 12, -5, 26, 106, 7, 118, -10, 36, -32, 9, -2, -19, -2, 22, -1, 14, -3, -87, 21, -9, 7, 76, -19, 36, 9, 7, -2, 21, 9, -10, 1, 88, 7, 7, -64, -11, 19, 24, -3, -1, 75, -86, 2, 32, 122, -3, -10, 82, 127, 22, 65, -128, 21, -90, -24, -19, 26, -96, 2, 14, 127, -3, -5, 80, 65, 127, -2, -107, 9, -97, -30, 19, -14, -75, 7, -9, 107, -63, 5, 30, 37, 84, -100, 66, 25, -91, -19, 30, 52, -42, -12, 21, 19, -45, 10, -26, 55, 52, -36, 91, 32, -26, -1, 29, -75, -3, -15, 45, -22, 12, -9, -1, 41, 7, -32, 104, 26, 63, -25, -1, 19, 1, -12, 53, -10, -22, 10, 70, 21, -11, -18, 113, 1, 127, -32, 21, 65, 2, 12, -22, -15, -7, -2, 47, 35, -30, 1, 2, 3, 44, -1, 32, 122, -1, -1, 29, 11, 3, 7, 66, 22, -24, -77, -22, -11, 36, -18, -22, 70, -44, 15, -21, 97, -2, 15, 89, 41, 15, 37, 25, -2, -55, -30, 11, 37, -30, 29, -14, 99, 1, 1, 91, 9, -3, 70, 21, 1, -11, -10, 5, -19, -29, 29, -11, 63, -63, -11, 58, 22, 45, -19, 37, 18, 15, 10, 5, 61, -59, 12, 12, 52, -74, -42, 42, -15, 82, -1, 74, 22, 9, -22, 15, 3, -30, 14, 30, 21, -21, 11, -25, 19, 59, -59, 70, 7, 74, -5, 12, 22, 7, 11, 30, -19, -45, -2, -9, -5, 14, -22, 118, -1, 61, -10, 29, 5, 9, -7, 24, -2, -30, 22, -10, -2, 30, -52, 5, 3, -25, -32, 7, 30, 21, 11, 26, -42, -22, 12, 65, -2, 1, 1, -2, 1, 29, 2, 11, 77, -47, 75, 52, 65, 25, 10, 3, 10, -10, 19, 25, 14, -12, -7, 1, 42, -35, 80, 21, 65, 30, -10, -15, 14, 11, 66, 37, 3, -2, -22, 30, 12, -25, 32, 5, 82, -21, 25, -21, -1, -2, 61, 1, 14, 22, -18, 18, 55, 15, 19, 15, 14, -2, -2, 9, -11, 63, 19, 12, 2, 41, -22, 5, -19, 9, 32, 15, 29, -44, 2, 5, -14, 74, -3, 36, 19, 24, -12, 12, 2, -9, -2, 5, 18, -7, -21, 15, -52, 30, -22, 75, 19, 64, -26, 5, -18, 9, 30, -10, -5, -30, 29, -91, -3, 15, -55, 44, 22, 44, -12, 5, 30, 32, 10, 12, -19, -64, -30, -128, -18, -10, -10, 3, 2, 74, -33, -34, -56, -88, -94, 4, 114, -40, -67, -54, -93, -122, -116, -60, -81, -39, -127, -74, -55, 33, -34, -103, -55, -75, -22, 19, -90, -128, -20, -106, 27, -88, -53, -92, 61, -16, -94, -86, 58, -73, -26, 3, -37, -108, -11, -30, -99, -30, -73, -92, 5, -27, -72, -120, -23, -97, -63, 36, -77, -25, -53, -66, 8, 89, -101, -44, -5, -12, -128, 33, 23, -14, -90, 76, -44, -105, -33, 6, -126, -28, -60, -6, 58, -50, -19, -17, 37, -128, -96, 58, -20, -12, -12, -24, 81, 85, -42, -74, -7, -65, -88, -7, 42, -60, -32, -128, -69, 116, -27, 8, -12, -16, -58, -78, -47, -14, -72, -34, 12, -100, 50, -97, -58, 42, 2, -17, -74, 86, -84, -12, 9, 9, -32, 23, 1, -90, -27, -4, 18, -42, -71, 28, -25, -78, 6, -92, 31, 51, -80, 83, -58, -90, 2, -58, 4, -42, 5, -16, -128, -10, -17, -111, -1, -40, -60, -30, -71, 17, -44, 127, -123, 86, -26, -85, -128, -31, -111, -100, -26, -15, -28, -64, 25, -82, -99, -6, -115, -48, -18, -72, -117, 10, -18, -19, -4, 58, -90, 7, 11, -117, 9, -69, -2, -24, 7, -128, -128, 24, 9, 16, 36, -80, -128, 13, -45, -86, -4, -8, -4, -83, -12, -75, 8, -18, -128, -100, -96, -6, -30, -28, -76, -117, 30, -12, -80, 83, -41, -58, -10, 15, -67, -120, -128, 55, -100, 127, 63, -88, -15, -5, -40, -6, 4, -45, -65, 37, -26, -67, 30, -47, -66, 28, -120, -73, -66, -58, -99, -60, -97, 26, -32, 63, -102, -81, 45, -112, -25, -24, -98, -69, -11, -106, -47, -88, -3, 18, -60, -1, 7, -83, 37, -12, -4, 73, -56, 3, 61, -12, -50, -77, -39, -7, -60, -64, -23, -39, -17, -63, -56, 26, -107, -116, 17, 86, -97, -102, -58, 47, -28, -34, -73, -54, -32, -128, -16, -74, -25, -64, 7, 34, -33, -27, -30, 121, -67, 18, -80, -49, 92, -126, -93, 40, -34, -43, 54, -43, -20, -93, 72, -114, -31, 26, 11, -69, -3, -42, -82, -74, -63, -40, 11, 30, -42, 78, -26, -43, -56, 86, 9, -76, -14, -35, -48, 9, -63, -107, -50, -22, -45, -23, 25, -24, -45, 55, -55, -117, -84, -76, -78, -12, -74, -65, -44, -92, -53, -25, -3, -6, -48, 41, -42, -89, 61, -6, 2, -12, -112, -36, 39, -71, -50, -88, -34, -1, -92, -47, -77, -109, 50, -74, -48, -35, -19, -116, 6, 72, -90, -66, -40, -35, -16, 10, -1, -66, -1, -96, -26, 13, -40, -82, -33, -42, -128, 18, -35, -40, -49, 37, 56, -44, -17, -75, -123, -42, -128, -83, 51, 18, -27, -17, 64, -97, 1, 1, -5, -114, -31, -63, -128, -50, -110, -92, -5, 8, -100, -40, -34, -58, -54, 14, -58, -128, 16, -128, -128, 25, -26, -55, -28, 45, -73, 73, 15, -88, -60, -36, -55, -76, 6, -36, -37, 26, -16, 2, -25, -47, -72, -22, 7, -74, -74, 32, -55, 55, 58, -72, 76, 41, -107, -87, 90, 24, -90, -41, 48, 19, -26, 76, -101, -19, -20, 8, -14, 6, -124, -121, 86, -83, 93, -28, 30, 47, -60, -61, -28, -71, -47, -128, -117, 6, -5, -77, -23, -94, -58, -102, -25, -26, -63, -34, -51, -26, 45, -84, -128, 78, -33, -61, -22, 48, -87, -50, 11, -30, -53, -28, -31, 12, 10, -127, 12, 40, -92, -120, 10, -7, -27, -90, -23, 89, -72, -14, -1, -25, -9, -45, -84, -28, -60, -128, 6, 5, -54, -67, 37, 127, -92, -75, -90, -44, -103, 78, -19, 23, -77, -3, 4, -73, -63, 127, 16, -128, -77, 12, -10, -98, -39, -64, -89, 34, -48, -101, -25, 44, 127, -69, 69, -51, -19, 80, -60, 63, 14, 14, -54, -74, -55, -72, 43, -63, -101, -84, -60, 20, -56, 76, -28, -116, 12, -3, -13, -11, -128, -45, 43, 8, -41, -26, -1, 31, -45, 47, 80, 73, 13, -56, -48, -56, -41, 1, -61, 19, -90, -94, -23, -11, -1, -9, 53, -27, -12, -109, -82, -9, -53, -97, 32, 50, -75, -60, 65, -15, -65, -20, 1, -66, 14, -58, -48, 13, -54, 15, 5, 6, -84, -61, 3, 60, -81, 67, 86, -98, 54, -61, -3, 54, -92, -43, -69, 28, 11, -71, -19, 123, -50, -25, 8, -87, -47, -12, 6, -25, -6, -58, 2, -56, -24, 8, -2, -109, -105, -63, -26, -128, -35, -84, -84, -30, -72, -50, -24, -24, -1, 39, 74, -20, -82, -10, 5, -51, -35, -7, -127, 24, -9, -101, 127, -109, -61, -36, -96, -6, -88, 26, -93, -45, -4, 22, -63, -15, -71, -111, -16, -56, -22, -58, 28, 49, 1, 43, 18, 125, 5, -28, -18, 1, -66, -33, -50, -56, -26, -22, -56, -1, -75, -50, -10, -88, -39, -58, -28, 77, -53, -55, 36, -47, -72, -128, 22, 61, -88, -35, -20, -81, -32, -99, -41, -31, -82, -48, -22, 43, -109, -16, -25, -47, -13, -28, 19, -47, -58, -90, -58, 10, -128, -44, -1, 10, -45, -28, -64, 127, -5, -63, -8, -121, -55, -58, -73, -24, -77, -121, -19, 27, -72, -99, -10, -58, -89, 71, 58, -114, -61, -116, -88, 27, -87, -47, 78, 20, 13, 20, -16, -15, -110, -54, 76, -63, -3, 43, -100, -44, -49, -66, 63, -13, -30, -90, 41, -58, -14, 19, -104, -28, -9, -98, -83, 15, -128, -124, 15, -60, -80, -48, -55, 71, -71, 14, 24, -90, 24, -128, -99, -31, -128, -109, 5, -87, -128, -41, 10, -3, -128, -30, -11, -55, -13, -128, -128, 7, -88, -18, 49, -25, 2, -78, -69, -3, -37, -18, -44, -111, 72, -19, -54, 30, -56, -19, -43, -27, 42, -43, -30, -45, -122, 20, -58, -115, -66, -103, -6, -49, -72, -53, -28, 58, -82, -128, 30, 89, -87, -28, -2, -42, -49, -2, -65, 50, -103, -90, -14, -48, -108, -44, 30, -32, -11, -42, 28, -90, -58, -86, -5, 19, -39, -106, -23, 49, -56, -85, 24, -84, -85, 117, -19, 31, 13, -51, -9, 48, -128, -104, 42, -63, -128, -42, -30, 24, -37, -11, 6, -82, 2, -63, 7, -1, -8, -39, 24, -54, -1, -128, 1, -86, -55, 53, -12, 45, -1, -106, -124, -48, -99, -76, 65, -128, -105, -63, -7, 14, -86, -54, 34, 73, -45, 2, -73, 17, -17, -117, -16, -61, -117, -54, -69, 41, -50, -18, 18, 32, -16, -67, -24, -16, 15, -76, 5, -44, 7, -34, -4, -86, -90, 14, -18, -42, -33, -128, -128, -18, 2, -45, -35, 1, -12, -22, -33, 66, 4, 4, 37, -53, -61, -125, -125, 67, -33, -73, 10, -9, -108, -71, -45, -22, -30, 15, 32, -61, -12, -65, -112, 7, -128, -128, 5, 32, 74, -80, -65, -1, -10, -90, -31, 42, -20, -50, -39, 127, -24, -76, 4, 35, 69, -10, 117, 33, -111, -27, -45, -87, -6, -37, -84, -5, -54, -96, -65, -99, 2, -65, 45, -12, -103, 13, 37, 20, -75, -13, -89, 9, -9, -117, -28, -49, 7, -41, 73, 2, -76, -20, 18, 47, -73, 82, -56, -27, -89, -51, -7, -20, -55, -58, 47, -64, -31, -44, 34, 87, 20, -63, -61, -37, -58, -77, -1, -103, 9, -80, -15, -76, -122, -37, -1, -6, -48, -3, -82, -48, -128, 25, -22, 1, -75, -49, -89, 69, -90, -24, 15, -123, 103, -42, -56, 67, -20, 97, -4, 41, -105, 9, 2, 9, -8, 12, -44, -40, -78, -128, -49, -12, -8, -81, 11, 25, -121, 17, 7, 13, -74, -5, -54, -87, -34, -8, -74, -128, -66, -84, -14, -17, -1, -65, -3, 4, -78, 14, -43, -92, -10, -98, -117, -13, -115, -66, 50, -41, -86, -122, 47, 31, -72, 51, 69, -128, -85, -81, -117, -86, -54, -81, -27, -85, -128, -128, -4, 24, -72, -12, 37, 26, -75, -103, -96, 27, -28, -83, -18, -81, -10, -107, -25, 51, -20, -19, 31, 50, -94, -128, -90, -40, 13, -73, -17, -85, -34, -49, -56, 88, -112, 80, -80, -88, -49, -61, -37, 33, -128, 19, -6, -28, -128, -48, 127, 103, -128, 58, 48, -16, -19, -64, -128, 10, -39, -7, -10, -5, 83, -17, 58, -89, -3, 74, -11, -77, -128, -37, -34, 31, -128, -67, -58, 50, 111, -60, 123, -73, -84, 11, -15, 85, -75, -44, -32, 77, -14, 45, 20, -117, -90, -128, -128, -6, -123, 51, -78, -12, 104, -83, -114, -37, -73, -71, -42, -99, -44, -90, 76, -3, -115, 36, 26, -37, -56, -42, -94, -4, -120, -54, -31, -90, 10, -77, -47, 14, -94, 77, -54, 101, -41, -39, -128, 16, -89, -3, -31, -54, 20, -33, -6, 23, -11, -13, -3, -69, -80, -90, -33, -22, -83, -22, -54, -63, -37, -78, 24, -50, -16, 22, 61, -1, 14, -77, -43, -31, -111, -4, 2, -5, -77, -72, -19, -69, -84, -11, -65, -12, 20, -89, -100, 23, -128, 3, -4, -102, 90, -111, 78, -88, -128, -84, -25, -63, -12, -17, -9, 5, -96, 1, 26, -43, 76, -76, 73, -48, -58, -104, -81, -38, -65, -104, -71, 32, -34, -27, -84, 58, 124, -45, 127, -37, -104, 93, -41, -10, 71, 34, -58, -51, -47, -34, -104, 72, 65, -38, 66, -128, 1, 83, -25, -128, -3, -8, -44, -117, -6, -54, -42, -6, -95, 127, -66, -1, -105, 56, 9, -1, -16, 21, -72, -81, 28, -13, -29, 90, -115, 7, -52, -13, -60, 72, -104, -102, -29, 9, -128, -8, 8, -56, -49, -34, -98, 4, 31, -66, -119, 4, -18, -128, -4, 35, -82, 32, 52, -18, -111, 6, -41, -66, 12, -86, -41, -13, -128, -128, -69, -38, -47, -86, 7, -35, 5, 25, -128, -11, 45, -16, -81, -71, -103, -71, -69, 29, -9, -79, -10, -124, 14, 40, -69, 3, 61, -65, -93, -80, -22, -117, 15, 54, -74, 7, 37, -80, -19, -128, 43, -24, -40, -41, -18, 65, -18, -128, 3, 62, -75, 13, 66, -74, -51, 30, 25, -16, 61, -22, -97, 60, -119, -80, -38, -93, -122, -20, -7, 19, -89, 66, -116, -128, -20, -117, -93, 8, -70, -77, 4, 41, -117, -1, 36, -43, -15, 54, -21, 114, -38, -27, -37, 70, -37, -32, -34, 18, -52, -44, 65, -86, -127, 81, -84, 77, -2, -84, -121, -34, -118, -105, -12, 3, -110, 9, -49, -22, -10, -93, -51, 41, -45, -91, -109, -43, -128, -72, 127, -84, -128, -51, -29, -117, -21, 127, -96, 44, -40, -32, -37, -14, -19, -104, -80, 124, -128, 10, -12, 1, 5, -51, -71, 47, 90, -128, -54, 4, -102, 42, 19, -28, 102, 64, 121, -128, -34, 32, 80, -128, -2, 4, -107, -1, -48, -60, -86, -84, -70, -10, 35, -103, -82, 127, 105, -65, -29, 6, -77, 19, -83, -128, 55, 81, -29, 22, 6, -82, -32, -36, -55, -128, 54, -18, -29, 8, -43, -128, -42, -5, 9, 69, 84, -66, -49, 66, -79, 88, -22, -45, -79, -14, -89, -44, -102, -10, -56, -30, 49, -105, -49, 32, -102, 93, 7, 49, -44, -64, -55, -13, 123, 127, -7, 2, -113, -79, 81, 2, -90, 98, 40, -128, -28, 3, -47, -47, -42, 125, -6, 15, -36, -128, -31, 25, -107, 37, 62, -128, -47, -66, 49, -118, -54, 103, -27, -91, -49, -128, 4, -10, -44, -9, -94, -61, -128, -90, -45, 12, -31, -128, -15, -72, -45, -5, -128, 41, 14, -90, 55, -89, -82, 49, -128, -96, 11, 21, -128, 22, -66, 10, -75, 102, -74, -128, -4, -4, -36, -11, -91, -54, -86, 104, -105, -45, 52, -88, 61, 41, -55, -112, -47, -21, -68, -18, -18, -100, -18, 86, -15, 2, 58, -47, -37, 64, -81, -122, -29, 6, -71, 9, -34, -71, -9, 62, -54, 38, 97, -1, 79, 1, -32, -37, 8, 55, -128, 10, -18, -120, 21, 75, -81, -38, -116, -128, -29, -4, -77, -22, -5, -54, -60, -29, -88, -79, -58, 7, -69, -71, -124, -4, 30, 54, -5, 47, 11, -93, -128, 29, -29, -71, -86, 91, -94, -55, -62, -37, -21, 7, -25, -84, -24, -22, -84, -64, 105, 41, 22, 82, -90, -2, -120, 98, 47, -128, -34, -97, 75, 66, -128, -43, 70, 77, 11, -77, -97, 10, -27, -88, 127, 42, -91, -77, 16, -3, -30, -75, -29, 12, -27, -71, -70, -61, -91, -32, -69, 83, -61, -93, -61, 9, -44, 45, 7, -58, 27, 6, -25, -56, 31, -56, 27, 31, -65, -111, -30, 34, -21, 60, -22, -41, 5, 83, -100, -13, 77, -89, 29, -45, -102, -36, 4, 40, -45, 29, 14, -18, -10, 56, -28, -1, 62, -31, -3, -13, 3, -91, -18, 69, -125, -91, 51, -25, -128, 71, -117, 71, -95, -77, 2, 16, -44, 51, -25, -66, -37, -94, -3, -116, -77, 49, -128, 75, -36, -55, 28, -24, -45, -30, -22, -89, -88, 72, 127, 16, 38, 91, -13, -77, -100, 61, 38, -58, -112, -88, -77, 28, -47, 65, -15, 4, -13, -48, -16, 22, -75, 122, -48, -96, -86, -43, -13, -6, -1, 58, -31, -74, -24, -66, -69, 11, -40, 88, -15, 104, -121, -82, 38, 16, -65, -25, 5, -121, 43, -60, -110, 75, -75, -51, -4, 54, -90, -128, 45, -86, -110, 41, -64, -40, -13, -48, -42, 49, -18, -70, -35, 94, -65, -103, -30, -71, -60, 16, -25, -105, 70, -71, -89, 44, 14, -89, -64, 5, -20, -80, 45, -95, 12, 68, -61, -10, -45, -82, -84, -24, 11, -111, 32, -1, -128, -86, -47, -64, -35, 14, 42, -47, -66, -12, 13, -8, -56, -30, 4, -42, -64, -22, -54, -44, -91, 88, 64, -95, 12, 24, -97, -42, -15, -119, 82, -69, -83, -107, -123, -10, -41, 34, 72, 22, 34, -37, -128, -10, -70, 80, 45, -93, -128, -82, -84, 1, -93, 22, -68, 116, 55, -82, -40, -91, -128, 75, 2, -62, -96, -45, -14, 34, -36, -22, -3, -86, 15, -77, -119, 45, -122, 19, -10, -13, 2, -115, 27, 43, -35, -16, 11, -14, 7, -119, -64, -24, -69, -82, 6, -12, -61, -113, -36, -102, -28, -6, -36, -20, 119, -38, -10, 79, 6, -94, -1, -28, -80, -127, 1, -42, -89, -2, 6, -47, 120, -45, -27, -40, -21, -40, -48, 79, -41, -117, -16, -45, -61, 77, 8, -49, -128, -22, -91, 14, -117, -107, 36, 42, 11, -22, 32, -125, -68, 32, -25, 3, -27, -118, -124, -48, -84, -40, 15, -65, -13, -94, 58, 18, -34, -1, 75, 69, 3, -65, -104, 51, -82, -65, -77, -64, -70, -94, 36, 28, -77, 28, -91, 7, 80, -116, -103, 8, -68, -128, -80, -93, -31, -77, 6, -45, -31, 66, -28, -115, -4, -25, -128, -21, -77, -118, 44, -14, -77, -115, -14, 37, -54, -15, 29, -93, -6, -45, -65, -14, -93, -31, 77, 7, -110, -54, 5, -49, -55, 68, 36, -79, -81, 13, -86, -41, -51, -9, -2, 2, 41, -128, -62, -116, -38, -9, 30, -12, -12, -128, -54, -32, -80, -98, 9, 5, 75, 42, -3, -77, -115, -3, 29, -128, -83, 8, -66, 60, 10, -83, 40, 29, -16, -82, -30, -109, -49, -40, -98, -31, -54, -74, -90, 77, -64, -38, 79, -113, -86, -128, -41, -2, -35, 12, 74, 62, 14, -123, -112, 49, -90, -128, 64, -62, -37, -2, 27, 5, -44, 20, 62, 98, -29, -5, -127, -124, -38, -88, 4, -89, -52, -48, -6, -2, -54, -71, 14, 80, -11, -68, -123, 114, -96, -45, -24, -48, -34, -128, -24, -22, -60, -51, -54, 69, 22, -86, -18, -74, -20, -51, 21, -113, -124, -103, 90, 120, -58, -80, -8, -42, 22, -83, -71, -22, -22, -112, -22, 3, -111, -117, -48, 72, -116, 28, 44, -32, -51, -88, -22, 51, -116, -88, -15, 40, -118, -61, -16, -74, -96, -42, 9, -114, 7, -104, -19, 14, -112, -70, -12, 6, 4, -74, -45, -55, -79, -98, -9, 69, -9, -61, -109, -100, -35, -104, -21, -128, -36, -10, -91, -32, -90, -93, 42, 36, -5, -56, -22, -42, -118, -91, 45, -122, -44, -70, 97, -16, -89, 18, -1, 115, 37, 102, -1, -15, -11, -40, -28, -69, -90, -48, -22, -1, 8, -91, 55, 91, 14, 36, -105, -34, 8, -93, -21, -52, -107, -45, -4, 44, -25, 65, -51, 123, 8, 61, -2, 37, -58, -18, 8, -1, -104, -14, -2, 51, -45, 32, -31, -10, 16, -84, -49, -75, -113, -22, 13, -65, -60, -32, 45, 72, -128, -25, -5, -42, -81, -74, -128, 2, -3, 1, -48, -24, -51, -55, 9, -35, -48, 13, 18, -55, -22, -128, -127, 14, -29, -91, 52, -19, -61, -86, -55, -124, -81, -27, 35, 21, -122, 24, -60, -18, -56, -60, -74, -12, -25, -54, -80, 77, -77, 43, -83, -89, -83, -86, -25, -68, -6, -118, 25, -40, -66, -36, 1, -41, -69, 9, -31, -122, 62, -77, -93, -36, -102, -105, 89, -74, -45, -64, 118, -52, -105, 81, -40, 94, -117, -100, -107, -45, -89, -96, -10, -32, -48, -107, 47, 15, -93, -12, -41, -77, -128, -48, -54, -74, -52, -66, -25, -49, -91, -128, -128, -62, -104, 19, 11, -47, -37, -125, -72, -9, -75, 10, 83, -118, -22, -89, 117, -45, -56, 62, 2, -30, -105, 1, -113, -37, -18, -21, 34, 91, -54, -128, -89, -100, -84, -93, -49, -22, -128, -58, -128, -16, -12, -128, 11, -112, 90, -128, -62, -41, -55, -34, 7, -5, 8, -68, -128, 1, -84, -88, -5, -91, -80, -105, -27, -45, -90, -15, -22, -3, 111, -66, -102, -38, -128, -24, -11, -122, -74, -2, 45, 61, -45, -62, 44, -20, -123, -79, -93, -12, -88, -18, 77, -22, -42, -9, -62, 27, -98, -41, -16, -95, -83, -28, -35, 41, -66, -28, -48, -95, -128, 6, -18, 16, -109, 48, 56, -65, 56, 7, -104, -54, -45, 11, -21, -32, -43, -44, 44, 22, -18, -22, -54, 118, 62, -47, -121, -80, -91, 30, 43, -128, 18, -115, -13, -1, -51, 34, 31, -128, 127, -62, -6, 6, -79, 1, 27, -42, -116, 1, 22, -40, -18, 5, -77, -71, -9, -52, -124, -10, -114, -113, 49, -70, -103, -80, 80, -70, -8, -51, -64, -37, -71, -109, -70, 55, 2, -89, -106, 39, -55, -2, 127, -10, -64, 127, -92, -4, -9, -7, -123, -47, 10, -30, -111, 5, 26, -38, 36, 84, -35, -109, 64, -70, 9, -38, 97, -109, -57, -119, -128, -63, -86, -63, -41, 57, 51, 53, -65, 2, -59, 81, 112, -48, 38, -53, -97, 116, -128, -115, 11, 98, -100, 87, -128, -1, -33, 46, 127, -79, 15, -59, -4, -36, -2, -37, -57, 96, -100, -11, -128, -83, -11, -16, -95, 47, 19, -30, -51, 39, -83, -52, 29, -128, -87, 93, -46, -114, 64, -4, -23, 75, -5, 1, -19, 42, 20, -11, 72, -28, -108, 26, -128, -53, -128, 5, -37, -124, -2, -123, 28, -56, -60, -11, -53, -101, 71, 114, -37, -128, -17, -48, -126, 48, 34, -93, -101, 57, -72, -36, 47, -10, -36, -84, -57, -118, 18, 37, -128, 7, -11, -76, -88, 104, 18, -7, -2, -23, -55, 4, -9, -90, -53, -86, -107, 15, -16, -64, -42, 71, 1, -128, -1, -116, -114, 72, -53, 83, -25, 82, 70, -36, -13, -20, -87, 123, -39, -26, 15, -128, -92, -10, -108, -122, -34, -37, 55, 36, -18, -70, 2, 34, -83, -100, 78, 53, -64, -37, 11, -81, 118, -37, -86, 27, -57, -128, -66, -112, 47, -107, 7, 27, 9, -73, -47, -81, 113, -48, -101, 43, 2, -34, -18, -78, -5, -34, -63, -75, 94, 52, -109, -19, -46, -47, -128, 46, -16, -71, 43, -44, -10, 46, 63, -90, -128, 23, 1, 72, 25, -47, -98, -52, 106, -102, -52, -52, 97, -100, 83, 1, -96, -44, 73, -94, 47, -38, -7, 44, 64, -106, -104, -92, -96, -128, 19, 65, -84, 15, -55, -128, 9, 127, -43, -25, -7, -27, 88, -85, -103, -119, 2, -33, -57, -64, 20, 38, -11, -15, -18, -86, -46, -70, 1, 30, -19, -33, -15, 2, -62, -20, 97, -128, -5, -35, -48, -39, -93, -55, 29, 86, -95, -55, 65, 2, -128, -26, -124, -10, -20, -7, -26, 65, -43, -70, -52, -60, 10, -88, 28, 64, -41, 10, -102, -57, 120, 104, -87, 47, -46, -36, 78, 41, -55, 13, 43, -72, -47, 76, -75, -25, -82, -109, -16, 23, 85, -2, 94, -16, -89, -20, -26, -18, -128, -36, 63, -36, -4, -42, -42, 59, -122, -84, -94, -13, -82, -63, 2, -18, -106, 4, 17, 21, 28, -90, -100, -13, -30, -73, -47, -26, -31, -76, 13, -48, -81, -28, 2, -43, -18, 41, -35, 9, -72, -43, 27, -30, -104, -112, 79, -46, -87, 1, -7, 118, -82, -10, -20, 37, -78, -71, -23, 20, -86, 125, 25, -119, -28, 1, 19, -87, 60, -41, -71, 76, -89, -67, 2, -38, -73, -31, -36, 10, -128, 42, -38, -9, -21, -42, -123, 1, -118, -38, -2, -79, 93, -116, 16, 92, -90, 26, 42, -59, 115, -68, -41, 20, -38, -60, -13, 21, 86, -92, -52, -89, -128, -13, -23, -117, -28, -128, -57, -75, -93, -128, -39, -88, -106, 44, -10, -111, -63, -16, -68, 36, 15, 65, 41, 31, -125, 20, -128, 75, -43, -120, 57, -66, -19, -1, -51, 56, 34, -34, -39, 8, -11, -4, -10, -73, 78, -72, -20, -34, -10, -71, 20, -47, 17, -95, -128, 73, 28, -95, -87, -128, -60, -59, -29, 60, -78, 4, -1, 66, 46, -57, -85, -9, -87, -128, 48, -19, -57, -79, 26, 115, -112, -13, -63, 86, 9, 41, -104, -34, -87, -109, 1, 29, -42, -73, 72, 56, -73, 51, -51, 86, 11, -30, -18, -9, -128, -88, -70, -55, 56, -90, -4, 106, -65, 39, -9, -87, 51, -34, -2, -23, -64, -56, 16, 57, 59, -93, -92, 44, -117, 90, -35, -128, -23, -78, -70, -10, -123, -128, 38, -35, 76, -42, 19, -72, -70, -86, -128, -29, -11, -115, -109, -93, -86, 55, 73, 106, -128, -47, -37, -52, -70, -34, -15, -78, -81, -78, -97, -95, -95, 1, 47, 34, -62, -29, 9, -84, -70, -5, 55, 111, 55, -128, -25, -46, -56, -48, -70, 62, -95, -84, -8, -46, 13, 2, 35, 25, -27, 67, -103, -1, -34, -88, -25, 23, -46, -51, -25, -47, -48, 36, 47, 101, 11, 55, -78, -29, 48, -34, -88, 5, 16, -68, -43, -62, -109, -35, 30, 41, 23, 8, -39, 7, -128, -59, -47, -25, -128, -65, 42, 35, -42, 30, 20, -39, 113, 42, -43, -30, -41, -62, -64, 63, 71, -7, -44, -27, -46, -7, 42, -101, 18, -41, -39, 93, -30, -9, 2, -63, 39, 7, -42, -128, -34, -2, 46, -78, -17, -34, -23, 43, -108, 28, 93, 70, -63, -33, 113, -70, -64, 52, -118, 64, 90, 90, -44, 72, -125, 19, 28, 115, 102, -47, -53, 16, -57, -28, -109, -62, 65, -62, -114, -1, -63, 103, 29, -57, -27, 2, -25, 70, -118, 60, -27, 97, 29, -39, 2, -7, -56, -83, 27, 26, -55, -128, -35, -43, -98, -42, 2, -89, 84, -39, -97, -81, -79, -117, 10, -17, -79, -55, -7, 30, -56, -83, 5, -28, -60, -96, -128, 31, -96, -23, 2, 41, -95, -78, -26, 37, -75, -8, 90, -95, 34, -17, -124, -70, -90, -39, -36, 63, -128, -15, 5, -42, -62, 15, 23, -128, -33, 9, -98, 5, -67, -81, 29, -28, 71, -73, -8, -119, -9, -33, -78, -43, 89, 89, -122, -90, -126, -126, -95, -4, -82, -19, -2, -64, -98, 43, -67, 46, 8, -114, -128, -53, -81, 118, -5, -11, -51, -70, -29, -65, -93, -33, -117, 75, 62, -29, -88, -33, -39, 101, -9, -96, -44, 93, -19, -1, -128, 29, 23, 83, -20, -42, -43, -28, -93, -120, 9, -18, -103, 33, -27, 82, -89, 25, 28, -98, -4, -46, -39, -1, -57, -113, -4, 11, -42, -103, 26, 11, -94, -35, -93, -5, 25, -41, -47, -1, -33, -52, 2, 64, 94, -13, 27, -5, -38, -46, -63, -119, 76, -20, -82, -15, -104, -60, -68, 13, -59, -118, 53, -62, -29, 20, 52, -81, -123, -46, 19, 47, -128, -37, -5, -17, -15, -20, 11, -103, -26, 47, -48, 37, -23, -98, 68, -59, -23, 96, 2, 20, -1, -88, -1, 43, -98, 9, -66, 79, -51, -104, -43, 66, -102, -128, -52, -56, -68, -88, 55, -23, -33, -25, 37, 111, 1, -128, -94, -37, -35, -120, -11, -107, -123, -119, 64, -75, -70, 17, -35, 96, 67, -87, -35, -17, -86, -66, -36, 11, -63, -119, -20, -60, -98, 78, 4, 89, -18, -47, -66, -9, -102, 87, 7, -15, -86, -37, -26, 96, -41, -19, -8, -59, 39, -86, -87, -1, -18, -128, -43, -18, -57, -53, -7, 95, -13, 23, -8, -67, 55, -128, -115, 42, -46, -65, 23, -2, 38, -34, -47, -36, -55, 25, 25, -98, -70, -128, -95, 28, -63, -101, -13, 37, -11, -34, 59, -72, -5, 94, 87, -86, 63, -2, -31, -118, -79, 127, 5, 60, -95, -44, 44, -1, -26, -78, 127, 11, -78, -57, -101, -43, -126, -23, -47, 71, -16, -2, 66, 59, -55, -36, -11, 59, -18, 64, -70, -31, 11, -81, 25, -33, -63, -128, 27, 36, -128, -38, -29, 84, 38, 88, -114, -5, -39, -128, -17, -57, -2, -48, 60, 53, -100, 5, 7, 116, -4, 23, -47, 35, -65, 28, 23, -56, -113, -95, -5, 5, -44, 41, 21, 41, -27, -125, -60, -27, -107, 10, 18, -48, -60, -104, 29, 34, -79, -5, 18, -34, 75, 11, -41, 36, -94, 60, -62, 39, -53, -128, 8, -41, 10, 46, 36, -123, -41, -125, -76, 20, -107, -102, -68, -16, -116, -124, -2, -59, -31, -128, 26, 93, 127, -62, -65, 5, -92, -19, 11, 112, -59, -98, 127, 34, -72, 52, -52, 10, -81, -9, -41, -34, 1, -31, 23, -93, 41, -116, 56, 70, -48, -29, 51, 101, 21, 41, -48, -2, 65, -76, 33, -119, -68, -96, -93, 66, -76, -72, -84, 28, -38, -5, -128, -23, 109, -84, 5, -5, -103, -63, -18, -34, -62, -18, 10, 127, 25, 63, -51, -128, -109, 1, 10, -128, -117, -100, -114, 1, -2, -47, -8, -1, -128, -9, -39, -11, -19, 28, 26, -36, -76, -26, -96, 59, -65, 66, 73, -90, -100, -81, -7, -28, 7, -51, 25, -30, 47, 13, -72, -67, -59, 17, 53, -128, -82, -2, -104, -10, -17, -87, 30, 11, 21, -93, -93, -9, -60, -128, 30, -47, -66, 44, 5, 9, -44, -128, 57, 1, -89, 124, 19, 18, -51, -51, -81, -21, -23, -2, -111, 21, -111, -47, -21, -73, 96, 68, 52, 16, -75, 56, 90, -43, -104, -26, -101, 26, -11, 25, 21, 9, 66, -123, -60, -23, -47, -44, -33, -62, 127, -44, -128, -67, -128, 27, -10, -71, -63, -33, 18, -23, -4, -92, -15, -18, 26, -64, -47, 46, -51, -21, 46, -9, 17, 86, 4, 71, -30, 71, -19, -47, 23, -98, -76, 37, -51, 57, 2, -19, -128, 95, 9, 2, -5, 23, -89, -90, 48, -128, -47, -5, -128, 2, -33, -62, 62, 97, 73, -109, -98, -2, -20, -5, -44, -42, -84, 19, -118, -20, 30, -25, -18, -62, -31, -55, -123, -81, -45, -43, -45, -1, -27, 31, 7, -84, -49, -1, -75, -67, -46, -92, -102, -93, -34, -65, -13, 75, -110, 127, 43, -35, -55, -35, -38, -44, -103, -67, 72, -74, -128, -128, -74, 18, -64, -126, -45, -106, -79, -15, -128, -39, 35, -57, -103, -98, -47, -64, -9, -15, -14, -98, 40, -11, -20, -85, -128, -29, -1, -128, -34, -41, -44, -122, -31, -57, -108, -48, 35, -40, -38, -15, -31, -80, 80, -128, -97, 4, -115, -48, -22, -33, -58, -64, -20, -102, -80, 33, 20, -101, -24, -81, -16, 127, -30, -93, -33, -45, -25, -84, 4, -72, -128, 48, -29, -24, -24, -18, -81, 74, -93, -106, -128, 45, -84, -48, 58, -31, -61, -51, -57, 8, 3, -40, -61, 118, -46, -66, 73, 9, -128, -34, -28, -28, -43, -3, -58, -25, 2, -12, -85, -110, -86, -93, -18, 2, -98, -64, 35, -55, -43, -76, 1, -49, 91, 39, -31, -20, -102, -94, -27, 28, -94, -31, 29, -114, -55, -57, -126, -128, 61, -103, -85, 10, -15, -87, -40, -16, -74, -11, 61, -88, -32, 12, -128, -60, -9, -122, -72, -33, -21, -80, 61, 47, -108, 25, -57, -64, -105, 51, -67, -47, -5, 92, -22, 25, -86, -107, -83, -1, 3, 46, 35, -83, 85, 16, -27, -20, -6, -86, -47, 67, -26, -70, 2, -65, -128, -54, 33, -108, 1, 29, -85, -48, -10, -104, -124, 16, -58, -8, -112, 34, -27, 82, 66, -123, 45, -49, -118, 1, 11, -41, -38, -9, 1, 112, 7, -81, -122, -5, 3, -108, -51, -30, -98, -70, -106, 26, -37, 24, -98, -42, 81, -92, -93, 16, -49, -69, -103, -16, -2, -45, -27, -3, -91, 41, -112, -13, 31, -48, -128, -26, -58, -128, -19, 3, -85, -52, 4, -25, -45, -11, -80, -93, -19, -67, -89, 66, -122, -91, 2, -69, -72, -128, 70, -70, -128, -33, -62, -43, 9, -108, -51, 65, -102, -98, -35, -8, -31, -74, 22, 10, -4, -21, -61, -55, -60, -81, 6, 24, -33, -58, 31, 1, -107, 19, -6, -128, -103, -58, -45, -104, -55, -38, -85, -43, -70, -110, 61, -45, -14, -8, 47, -87, -100, -64, 69, -32, -62, -128, -128, 60, -128, -57, -45, -34, -18, -11, -2, -1, -80, 16, 15, -6, 14, -91, -128, -69, -73, -42, -84, -35, -41, -128, -111, 31, -106, -48, 75, -112, 49, -46, -99, 16, -51, -43, 6, -81, -37, -128, 6, 29, -93, -43, 5, -128, 19, -114, -14, -26, -65, -128, 67, 61, 1, -73, -31, 34, -21, -19, -37, -26, 22, -128, -1, -39, -81, -31, -14, -45, -35, -76, -65, -26, -6, -37, 48, -101, 21, -82, -43, -87, -128, -54, 73, 20, -96, -117, 22, 1, -118, -3, -11, -3, -40, 9, -88, -31, -58, -93, -48, -14, 6, -55, -40, 16, -31, 7, -1, -102, 1, 3, -124, 15, -118, -35, 40, -27, 2, -33, -7, -128, -103, -24, 93, -79, -83, -74, -124, 74, -81, -58, -42, 27, -85, -48, 84, -107, 1, 20, -3, -19, 26, -48, -82, -1, -65, -102, -45, -112, 21, -79, 61, 19, -93, 48, -34, 34, 25, -41, -41, 24, -128, -76, -46, -31, -89, -128, 13, -7, -37, 32, -3, -128, 12, -88, -22, -46, -80, -35, 14, -57, -79, -54, -29, 61, -26, -7, 5, -104, 40, -16, -88, 16, 2, -22, 26, -6, -41, -33, -58, 117, -74, 24, -19, -114, 8, -54, -35, 54, -40, -117, 41, 12, -112, -83, -27, 82, -83, 2, -14, -85, 18, -67, -83, -13, 10, -97, -28, 25, -27, -88, -46, 127, -79, -1, -81, -89, -69, -73, -40, 4, -58, -91, -73, -1, -92, -43, 11, -54, -120, 29, 48, -88, -82, -19, -26, 66, -128, -87, 15, -26, 51, 43, 10, -100, -13, -46, -82, 9, -18, -18, -128, -55, -114, -31, -73, -15, -128, -38, 72, -21, -80, -62, -73, -62, 31, -80, -96, 10, -52, -114, -9, -48, -32, -108, -38, 19, -39, 1, -1, -103, -58, -93, -89, 45, -124, -107, -4, -67, -65, -42, 33, -1, -54, -72, 15, -37, 2, -65, -67, -30, -45, -75, -2, -74, -66, 1, 67, 6, -70, 47, 25, -103, 15, -79, -18, 43, -43, -34, -37, 14, -75, -72, 26, -98, -66, -37, 86, -19, 51, -108, 18, 16, -88, 3, 45, 82, -128, -128, 20, 100, -100, 3, 21, -19, -128, -47, -118, 4, -75, -28, 34, 44, -45, 70, 7, -58, -93, -7, 51, -96, -33, -124, -112, 20, -66, -115, -24, 14, -33, 41, -6, -2, -58, -11, -38, 22, -4, -6, -118, -91, -66, -100, -108, -84, -28, -21, 19, 93, -82, 62, -98, -103, -39, -91, -26, 7, -104, -83, -62, 18, -107, -43, -58, -54, -128, 8, -91, -87, -60, -45, 15, -28, -40, -124, -11, -42, -105, -115, 35, -61, -124, 88, 46, -128, -49, -74, -54, -31, -79, -105, -32, 11, -14, -57, -12, -6, -39, -24, -35, -98, 19, -86, -19, 91, -24, -80, -70, 21, -57, -66, -10, -49, 9, 38, -35, -22, 87, -58, -31, 7, -80, -42, 86, -3, -118, -34, 48, -54, -25, -22, -38, -126, -31, -65, -45, -55, -39, -52, 27, -64, -12, -124, 38, -42, -128, -40, 1, -76, -57, -89, -120, -14, -30, -74, -2, -2, -37, 3, 12, -118, -89, 45, -11, -28, -10, -94, -80, 2, -74, -7, -65, -37, -128, -26, -49, -31, -45, -28, -107, -19, -28, 5, -128, 43, -40, -55, -33, 6, -94, -57, -1, 41, -42, 55, 40, -51, -52, -98, -102, -43, -76, -72, -21, -7, -94, -83, -9, 38, -2, 16, 30, -28, -74, -98, -105, 26, -112, -118, -92, 12, -64, -18, -38, -25, -33, -86, -45, -103, 72, -102, -29, 11, -69, -103, -74, 80, -123, -1, 83, -70, -26, 2, 85, -70, 31, -38, -79, 83, -43, -128, -16, -13, -101, -47, -57, -29, -52, 92, 82, -26, -79, -87, -29, 55, -73, -128, -18, -67, -26, -67, 34, -109, -98, -35, -27, -48, -46, -108, -58, -22, -11, 12, -54, -65, -112, -51, 29, -57, -72, -76, -2, 75, -46, -35, -39, 14, -74, -92, -75, -60, -105, -54, 21, 21, -99, 81, -41, -64, 5, -51, -74, 18, -124, -41, 18, -44, -54, -128, 73, 41, -42, -28, -44, -120, -10, -87, -87, -18, -128, -87, -10, -97, -73, -26, 82, -44, -10, 25, 24, 38, 34, -121, -54, -40, -79, -75, 69, -66, -107, -92, 5, -16, 20, 84, 21, -51, -40, -115, 2, -33, -66, -80, -27, -61, -122, -67, 18, 98, -115, -62, 82, -124, 14, -12, -86, 12, -62, -105, 13, -11, -66, -85, -1, 67, -15, -21, -9, -61, -11, -93, -69, 16, -124, -112, 86, 51, -107, -28, 12, -66, -88, -24, -37, -25, -83, -21, -33, 42, -18, -72, -24, 27, -100, -64, -26, -80, -58, -54, -20, 46, -60, -11, -86, 22, -39, -104, 12, -112, -97, -58, -122, -10, -24, -52, -128, -8, 38, -22, -101, -44, -27, -128, -5, -41, -99, -24, 20, -12, -98, 69, 39, -72, -66, -25, -115, -20, -98, -122, -25, -26, -67, -38, 46, -65, -47, -38, 33, -82, -49, -48, -58, -16, -61, -128, 22, -92, -13, -69, -26, 1, -96, -40, -70, -94, -31, -8, -128, -3, -128, -76, -37, -57, -128, -73, -1, 76, -79, 1, -7, -29, -27, -43, -73, -67, -73, 127, 4, -47, 3, -96, -57, 57, -98, 41, 35, -88, -35, -44, -89, -1, -99, -3, 3, -82, -128, -57, -73, -76, -64, -49, -7, -101, -100, -44, -9, -57, -73, -128, 29, 21, 127, -29, -6, -104, -107, -1, 31, -9, -34, -10, -22, 3, -100, -128, -13, -99, -104, 15, -2, -7, -47, -24, -58, -102, -41, -101, -12, 46, -75, -67, 7, -35, -34, -73, -27, 38, -101, -21, 20, -66, -128, -84, -24, -128, -128, -66, -38, -121, -128, -85, -3, -4, 1, -58, -40, -84, -72, -76, 15, 49, -11, 1, 40, -49, -81, -128, -103, -6, -128, -25, -11, -8, -76, -72, -29, -34, -66, -39, 12, -29, 4, -101, 35, -2, -88, 57, 86, -93, -73, -48, -75, -51, -51, 60, -34, -83, -69, -54, 13, 25, -65, 73, 26, -91, -20, -83, -69, -9, -52, 27, 70, 18, -30, -123, 24, -124, -128, -61, 8, -5, -58, -30, -128, -29, -55, -81, -1, 33, -26, -38, -109, -70, 12, -74, 10, 10, -34, -47, 10, -22, -111, -65, -45, -67, -101, -75, 14, 44, -60, 12, -109, 20, 76, -45, -103, -75, -96, 1, -64, -115, -64, -73, 13, 12, 6, -16, -64, -75, -75, -79, -6, 34, -49, 58, -15, -42, -102, -72, -32, 26, -92, -13, -44, -30, 4, -45, -16, -2, -6, -21, 4, -45, -72, -106, 3, -20, -99, -41, -86, -28, -80, -96, -104, 41, -128, -20, -21, 3, -39, -37, 45, -73, -6, -75, 13, -128, -2, -128, -123, -49, -20, -44, -44, -48, -92, -128, -83, -103, -13, -5, 57, -81, 19, -82, -34, 37, -87, -15, 18, -118, 13, -12, -27, -87, 6, 32, 3, -92, -70, -75, -110, 40, -128, -47, 64, 34, -47, 3, -128, 11, 16, -93, -12, 5, 121, -1, -2, 28, 93, -86, 8, 15, 17, -82, 35, 76, 1, 105, -15, -2, 113, 48, -15, -1, 109, -45, -20, 40, 92, -39, 36, 37, 27, 85, -1, 11, 93, 73, -4, -15, 109, -92, -6, 11, 14, 92, 26, -7, 18, 22, -5, -6, 97, 85, -5, -8, 1, -128, 11, -6, 27, 82, -1, -48, -7, -35, -6, 11, -4, 6, -2, -33, 6, -94, 5, -30, 20, 119, -1, -28, -18, -22, 7, -5, -30, -53, -36, -31, -33, -41, -1, -82, 25, 115, -14, -41, 6, -30, -17, -1, -72, -36, -128, -60, -21, 8, -12, -117, 4, 48, -18, 3, -2, -28, 5, 6, -94, 18, -14, 14, -40, 21, -11, -93, -43, -49, 5, 7, -11, 3, -8, 14, 78, -62, -5, 18, 49, 127, 9, -4, -2, -107, -41, 95, -56, 116, 2, -2, 67, -66, 8, 11, 37, 72, 19, 3, 39, -75, -4, 76, 11, 121, -5, -2, 67, -8, 31, 27, 87, 50, -1, 33, -7, 4, 12, -43, -41, 74, -5, 6, 43, -77, -19, -3, 123, -40, -8, 15, -27, 83, 30, -109, -49, -40, -4, -8, 5, -89, -1, -43, -6, -110, 20, -51, 2, 83, -5, -104, -4, -124, 15, -5, -127, -100, -11, -122, -79, -120, -9, -119, 9, 86, -14, -31, -6, -128, -4, 11, -128, 2, 1, -114, -100, -15, -14, -128, -20, 25, 2, 21, -2, -74, 20, 9, -128, 2, -96, -26, -43, 53, -1, -105, -26, -85, 1, 17, 11, 2, 18, -4, 21, 127, -97, 2, 2, 99, -9, 14, -51, -31, -31, -27, -18, 117, -7, -5, 76, 127, -66, -35, 2, 64, 4, 70, 6, -83, -14, -109, 5, -35, 7, 12, 35, 127, -18, -41, 45, 105, -2, 93, -50, -104, 1, -66, 40, -43, 3, 9, 9, 4, 56, -55, 27, 12, -1, 75, -48, 67, -35, -75, 3, 45, -7, -9, 9, 4, 68, 3, 22, -4, -14, 55, 15, 3, -37, -66, -3, 17, 4, 7, -85, -8, -51, -42, -17, -78, 14, -12, 1, 33, -30, -19, 3, -128, -2, 12, -128, 4, -42, -64, -27, -36, 2, -95, -8, 5, -12, 2, 5, -128, -7, -5, -128, -2, -55, -3, -107, 14, -8, -62, 5, -35, -62, 26, -60, -14, 18, -2, -60, 120, 11, -48, -21, 39, 14, 4, -66, -11, -128, -25, 9, 96, -8, 1, -64, 96, -1, -77, -17, 62, -5, 25, -74, -35, -50, 97, 21, -24, 6, -9, -118, 42, 17, -119, -2, 117, 11, 56, -73, -51, -35, -7, 1, 55, -1, 2, -128, 22, 79, -97, 8, 74, 2, 55, -97, -55, -30, -68, -6, 121, -4, 3, -128, 74, 78, 14, -7, 21, -6, 30, -14, -109, -33, -90, -5, 40, 12, -11, -117, -30, 17, 3, 26, -5, 18, 36, -28, -114, -5, -117, -21, -128, 12, -2, -35, 17, -43, -12, 45, -25, 1, -73, -8, -110, -20, 4, 30, -128, -2, 3, 56, 11, -28, 9, -17, -53, -21, -86, 1, -1, -27, 20, 62, -87, 12, 4, 17, 109, 1, -64, -53, -76, 6, 30, -17, -43, -55, 75, 40, 83, -20, -17, 9, 121, -79, -79, -26, -76, -1, 90, -17, -27, -39, 75, 40, 73, -6, -2, -7, 93, 7, -92, 24, 73, -5, 122, -30, 5, -31, 33, -3, 73, 7, -17, -68, 60, 24, -128, 5, 99, 12, 127, -17, -50, -24, 19, 4, 109, -2, 4, -40, 31, 9, -62, -41, 67, 14, 45, 67, -37, -25, -62, -8, 97, -12, 12, 36, 39, -17, 30, -77, -24, 5, 15, 115, 4, -2, -128, -2, -36, 4, -8, 78, 3, -128, 55, 11, -73, -4, 17, 127, -87, -33, -12, 70, -128, 2, -8, 82, 3, -14, 9, -18, -117, 11, -18, 27, 48, -8, 1, 74, -100, 20, 7, 20, -45, 8, -77, -55, 127, -19, -4, -50, -122, -7, 94, -60, 76, 12, 15, 48, 92, 114, -76, -33, 86, -2, 22, -14, -128, -3, 78, 42, 56, -2, -4, 40, 4, 20, -3, 11, 83, -1, 66, -27, -82, 7, -2, 1, -5, -15, 11, 31, -53, -18, -14, 64, 45, -5, 126, -37, -9, -42, 33, -8, 33, 15, -8, 73, 20, 48, 48, 127, 90, 1, 68, 73, -3, -35, 30, 6, 56, 8, -1, 89, 43, 100, 105, 55, 60, 1, 12, 118, -8, 40, -26, -1, 7, -4, -19, 70, -12, -36, 83, -60, -60, 6, 19, 127, -40, 90, -2, -5, -94, -1, 19, 75, 7, -62, 60, 21, -118, 9, -56, -48, 83, 92, 11, 48, -83, -4, 7, -6, 124, -76, -55, -19, 86, -7, 40, -3, -97, -1, -79, 6, -17, -8, 6, 25, 127, -37, -40, 7, 118, 17, 67, -39, -124, 27, -75, 2, -95, 11, -2, 37, 37, -1, 6, 64, 127, 2, 100, -14, -128, 12, -95, 28, -115, -6, 5, -2, -1, 9, 68, 76, 118, -14, 89, -21, 6, 4, 1, 30, -55, 4, -21, -4, 36, 51, 124, 77, 110, 3, 76, 17, 36, -43, 106, -4, -55, -12, -3, 91, 14, 28, 127, 92, 73, 4, 4, 49, 18, -2, 86, -73, 94, -6, 2, 100, 9, 49, 76, 76, 6, 7, -28, 72, -33, 102, 60, -19, 115, 12, 9, 104, 18, -11, 30, 127, -78, 11, -3, -97, 2, 127, 18, 51, 21, -2, 15, -24, 19, -19, -26, -6, -28, -9, 37, 74, -40, 3, -74, 6, -27, -2, -6, -24, 22, -18, -11, 53, 86, -2, 27, 30, -77, 1, -15, -5, -96, 8, 2, -56, 37, -6, -18, 39, 122, -7, -1, 48, -128, -22, -15, 37, -90, 7, -8, -75, 20, -40, 20, 72, 77, -3, -14, -21, -105, -41, 19, 19, -6, -3, 2, -97, 67, -31, 92, 56, 66, 17, 30, -86, -51, -74, 91, 8, 41, -7, -12, -60, 8, 15, 99, -27, 79, -11, 56, -72, -5, -121, 127, -9, 106, -2, -19, 49, 12, 110, 70, -43, 100, 1, 53, -17, 11, 6, 49, 3, 107, 6, 1, 79, -12, -128, -15, 123, 51, -9, 40, -83, -114, 106, -7, 76, 86, -15, 12, 35, 33, -5, -68, 27, -76, 7, 41, 19, 4, 70, -66, 36, -75, 6, 15, 22, 67, 8, -42, 50, -11, -14, 35, 19, 19, 15, -67, -17, -60, -2, 3, -41, 15, -3, -56, 60, 77, 1, 8, 53, 15, -20, -4, 2, -110, -4, -11, -60, -21, 37, -39, 14, 110, -5, -2, 6, 21, -39, 25, -2, -22, 5, 6, -40, 87, -15, 14, -82, 77, 15, 14, -40, 67, -55, 70, -17, 22, -8, 2, -12, -22, -27, 30, -86, 73, -12, 64, -26, -40, -102, 93, -1, 85, 5, -18, 22, -1, 127, 36, -113, 96, -12, 102, -18, 28, -118, 62, -78, 91, 1, -4, 78, 2, 39, -20, -128, 116, -7, 53, -43, -20, -20, 4, -12, 74, 9, 2, 21, 56, 93, 9, 45, 106, -11, -41, 56, -24, 43, -19, 8, -67, -17, -7, 19, 68, 99, -28, 42, 2, 11, -20, 45, -41, 45, -33, 3, -68, 9, -4, -12, 43, 2, -4, 50, -45, 7, -9, 30, 8, 67, 35, -1, -66, -6, 6, -18, 8, -15, -8, 24, 31, -6, -19, 15, 19, -21, 35, -15, -1, 7, -2, 3, 75, 70, 19, -35, 21, -5, -8, 27, 39, -19, 55, -2, 15, -8, 7, -15, 4, -43, 6, -49, 19, -6, 17, 20, 66, -15, 70, 21, 50, 8, -6, -17, 4, 91, 1, -36, 41, 9, 77, -5, 64, -31, 30, -116, 78, 12, -1, -66, -1, 36, -48, -82, 127, 2, 50, 26, 4, 35, 33, 1, 76, 15, -14, 45, 127, 40, 31, 33, 99, -12, 11, 67, -56, 19, -68, -4, -25, 8, -3, 22, 82, 95, 21, 48, 75, -1, 24, 75, -73, 1, -105, -90, -79, -2, 5, 27, -17, 68, 24, 68, 15, -3, 15, 24, -25, 39, -28, -75, -93, -19, 9, -17, 19, -15, 45, 76, -20, -20, -4, 90, 7, 26, 28, 8, -36, 18, -19, -4, 77, 72, 33, 25, 6, 17, 19, 50, 14, 20, 75, -14, 33, -3, 19, 27, -40, 103, 22, -3, -30, 1, 42, 67, 26, 66, 17, -113, 21, -6, 20, 53, -6, 123, 24, -19, -35, -4, 72, 40, 30, 85, 17, 48, 127, 2, -18, 19, 11, 51, -5, 6, 42, -19, -48, 51, 19, 66, 17, -43, 36, 6, -14, 20, 22, 6, 22, 31, 40, 1, 53, 35, -21, 4, -40, -42, -9, 8, -2, 19, 50, 31, 28, 36, 39, 7, 73, 64, -20, 20, -82, -20, -27, -4, 12, -1, 48, 42, 27, 62, 33, -33, 45, 33, -48, 18, -50, -41, -75, -8, 12, -20, -20, -60, 15, 67, 12, -26, 48, 33, 18, -1, 1, 21, -55, -2, 1, 11, 27, 2, 48, 62, 12, 22, 17, -2, 8, 30, 28, 64, -9, -4, -6, 60, 37, 118, 53, 22, 8, 14, 55, 97, 12, 48, 18, 27, -5, -9, 14, 82, 35, 25, 56, 9, 22, 24, 17, 62, 26, 66, 17, 85, 68, -6, -4, 50, 12, 109, 37, 21, 51, -12, 55, 35, 35, 86, 25, 127, -27, -22, 10, -17, -124, 2, 65, -4, 24, -14, -59, -34, 4, 17, 59, 3, 46, 16, -6, 49, -114, -12, 78, -19, -20, 18, -107, -61, -20, 23, -20, 19, 60, 24, -36, 59, -88, -2, 115, -27, -31, -3, -121, -54, -45, 9, -90, 6, 14, -6, -20, -27, 82, -7, 27, -12, -40, 29, -87, -55, 105, 51, -128, 39, -40, -3, -16, -39, 110, -2, 32, 35, -23, 42, -77, -57, 126, 16, -128, 10, -128, -22, 23, -19, 126, -16, -1, 31, -32, 12, -65, -56, 115, -7, -108, 18, -90, -9, 34, -51, 93, -29, 1, 2, 12, 4, -20, -56, 28, -4, -33, -10, -48, 5, 6, -73, -12, 7, 25, 42, 65, -11, 10, -55, -10, -10, 28, -5, 6, -3, -4, -86, -32, -2, 78, 4, 12, 5, -128, -33, 42, -115, 72, 3, 78, -4, 29, -64, -50, 12, 96, -95, -58, 11, -96, -18, -6, -77, 71, -2, 124, 14, 11, -48, 95, 16, 98, -89, -35, 18, -58, -19, -52, -45, 33, -4, 107, -5, -11, -77, 109, -4, 27, -90, -27, -4, -60, -51, -28, 1, -73, -6, 90, -5, -2, -46, 126, 28, -11, -54, -22, 25, -43, -51, 2, -39, -115, 7, 48, 2, -24, -89, 126, 1, -20, 3, -2, -6, -12, -70, -11, 18, -122, 4, -27, -5, 9, -95, 4, 23, -2, 18, 78, 10, 11, -43, -20, -11, -27, -17, -42, 5, 31, -71, 3, 12, -12, 31, 97, 1, 29, -28, -69, -3, -4, -22, 40, 12, 4, -82, -42, -40, 45, -82, -51, 34, -128, -36, 39, -128, 126, 18, 122, 12, 12, -23, 65, -32, 40, -128, -57, 22, -128, -24, 19, -128, 126, -14, 126, 2, 5, 14, -25, -51, -7, -128, -74, -5, -128, -16, 24, -78, 76, -22, 126, 20, -29, 71, 12, -59, -64, -119, -84, -10, -51, -23, 1, -25, -29, -11, 114, -1, -22, 57, -1, -51, -91, -75, -59, -1, -89, -33, 43, -36, -124, -4, 36, 23, -20, -49, -19, -1, -77, -74, -17, -11, -29, -7, 35, -95, -105, -9, -17, 19, -33, -79, -17, 40, -61, -87, 12, -23, 117, -5, 64, -19, -59, -1, -24, 18, 9, -41, -31, 41, -38, -22, 75, -22, 40, 39, 29, -32, 3, 5, 2, -20, 31, -18, -109, -58, 19, -38, -89, 20, -23, -39, 31, -96, 126, 9, 103, 9, 28, 45, -42, -59, 2, -74, -91, -3, 18, -40, -6, -124, 93, 7, 126, 3, 12, 102, -16, -42, 12, -105, -88, -6, 48, -5, 33, -86, 10, 1, 126, 10, -42, 117, -64, -9, -33, -128, -101, -10, -56, 14, 71, -65, -43, -16, 93, 31, -28, 126, 24, -1, -72, -73, -58, -5, -70, 29, 126, -17, -91, -10, -22, 5, -14, 126, -22, 3, -70, -39, -49, -12, -36, 20, 102, -25, -78, -22, -72, 18, -7, -3, -34, 41, -12, 5, -9, 9, -16, -7, 126, 33, -31, 4, -45, 18, 20, 17, 29, 38, -11, 14, 40, -35, 126, 29, 87, -20, 34, -4, 1, -4, -16, -12, -128, -35, 22, -58, -55, 1, -78, -19, 35, -72, 86, 12, 71, 18, 1, 32, -109, -35, 28, -87, -54, -11, -78, -6, -7, -74, 72, 27, 126, 20, -16, 68, -45, -33, 18, -88, -57, 4, -74, -2, -5, -88, -5, -19, 87, 12, -11, 71, 1, -42, -12, -76, -70, 5, -57, -5, -9, -68, -90, -1, 45, 24, -14, 73, 59, -3, -28, -51, -45, 2, -82, 1, 16, -46, -75, 12, -10, 19, -19, 38, 6, -5, -5, -1, -39, -5, 18, -16, -12, -19, -58, 12, -69, 17, 6, -45, -12, -1, 4, 51, 2, -10, 9, -23, 57, 17, 25, -11, -51, 12, 24, -10, 12, 18, 46, 69, 42, -16, 14, 11, 5, 5, 46, 7, -11, 2, 7, -24, -52, -17, 52, -32, -31, -9, -12, 2, 63, -23, 63, 1, 82, 2, 11, -6, -58, 12, 70, -77, -57, -11, -19, -2, 68, -39, 82, 5, 126, 4, 4, -1, -20, 11, 3, -57, -45, 12, -16, 11, 41, -34, 35, 11, 82, -1, 23, -1, -23, 28, -27, -86, -22, -2, -64, 6, 36, 12, -78, 6, 78, 16, 28, 33, 20, 2, -32, -32, -1, -4, -24, 3, -10, -14, -96, 20, 40, -4, 7, -31, 17, 34, -31, 31, 40, -1, -46, 1, -29, 11, -52, 12, -45, -9, 22, -41, 4, 16, 18, 59, 50, -3, -12, -20, -4, 38, -9, -14, -7, 12, 7, -12, 12, 38, 5, 40, 56, -10, -33, 2, -38, -12, 58, 20, 29, 4, -3, 7, -82, -25, 35, -3, -20, -17, -46, -25, 35, -19, 90, 32, 84, 7, -7, 32, -19, -32, 56, -71, -56, -1, -28, -14, 60, -70, 68, 16, 124, 4, 1, 17, -12, -38, 19, -70, -58, -17, -11, 2, 49, -25, 42, 24, 58, 2, -10, 29, -107, -24, -29, -84, -39, 19, -24, 3, 35, 45, -20, -1, 51, -2, -18, 49, -40, -1, -42, -27, -14, -12, -4, -3, 38, 51, -87, -14, 29, 11, -23, -23, 23, 16, -43, 6, -9, 2, 23, 20, -11, 84, -52, 12, -32, 23, 2, -49, -22, 34, 17, 40, 28, -9, 57, -1, 11, 101, -34, 25, 7, -1, 9, -4, -3, 20, 11, 3, 31, 9, -6, 12, -4, 1, 25, 23, 18, 11, 4, -18, -70, -12, 24, -14, -22, 1, -28, -22, 12, -31, 72, 25, 77, 4, -14, 48, -40, -22, 4, -60, -61, 4, 70, -24, 9, -33, 41, 18, 84, 24, 33, 97, 22, -12, 4, -20, -58, -5, 59, 14, 29, 12, 14, 19, 60, 9, -35, 88, -31, -28, -12, -41, -45, -4, 59, 14, 16, 16, -14, 2, 28, 10, -32, 103, -39, -6, -48, 1, -27, 1, 55, 18, 100, 68, -46, -12, 2, -12, -3, 93, -63, -1, -23, 54, -12, 3, 7, 7, 56, 77, -24, -7, -36, 18, 7, 79, 2, 27, 35, 42, -27, -22, 57, 31, 5, 57, -12, 10, 1, 12, 29, 72, 9, 33, 40, -10, -10, -12, 41, 39, 75, -28, 22, 2, -2, 22, -2, -55, -17, -1, 27, -32, -14, -10, -78, 12, 25, -17, 61, 28, 59, 9, -28, 19, -23, -32, 22, -52, -11, -5, -89, -14, -14, -19, 24, 1, 101, -11, 7, 78, -25, -9, 29, -38, -31, 12, -48, 10, -63, 45, -29, 12, 48, 32, -4, 36, 1, -9, 28, 11, -16, 6, -36, 27, -32, 49, -33, 14, 32, 6, -25, 65, -12, 14, 2, 23, -38, -14, -45, -6, 45, 63, -55, -1, -11, 24, 22, 57, -12, 17, 6, 36, 11, 9, -59, -11, 76, 58, -7, 7, -39, 1, 14, 78, 12, 19, 73, 56, -20, -6, -115, 4, -18, 89, 23, -7, -33, 3, 29, 20, 6, 4, 60, 58, -52, -2, -34, 28, 40, -23, 19, 11, 32, 5, 9, -59, -38, -16, 33, -33, -41, 12, -20, -25, 27, -54, 63, 45, 72, -1, -29, -12, 48, 7, 45, -56, 7, -2, -31, -2, 31, -7, 40, 12, 90, 3, 3, 12, -42, 61, 19, -42, 28, -17, 2, -6, -4, 32, 6, 5, 65, 28, 1, 9, -43, -12, 6, 5, -7, 5, -28, 25, -43, 76, -25, -1, 45, 19, 5, -12, -33, -51, 12, 68, 28, -2, -5, 18, -48, 31, -33, 14, 9, 32, 19, -11, -23, -14, 16, 54, 29, 2, -34, -25, 43, 9, -52, 29, -18, 45, 24, -16, 39, 33, 33, 51, 38, 1, -63, 3, -12, 58, 35, 18, -6, -3, 11, 63, 9, 12, 71, 49, 1, -1, -100, -7, -19, 109, -3, 1, 45, 3, -2, -34, -32, -58, 11, -49, -55, 12, 33, -7, 12, -20, 54, 29, 43, 22, -23, -33, 10, -65, 9, -38, -17, 11, 84, -4, 35, -51, 75, 28, 61, 19, -2, 28, 79, -24, 35, -69, 28, 1, 100, -11, 39, 6, 14, -5, 72, 41, -16, 34, 33, 12, 5, -5, 29, -2, 32, -6, -9, 11, -29, -12, 36, 20, 4, 3, 3, -54, 5, 24, 2, 7, -50, -17, -9, 9, -41, 7, 17, 27, 3, -56, -64, -59, -6, -9, 25, 16, -12, 18, -41, -51, -51, 25, 18, 32, 27, -46, -18, -77, 35, 12, 58, -9, -24, -5, 24, -40, 40, 1, 41, 10, 24, -20, 24, 11, 31, -10, -32, -24, -41, 4, -28, -34, 17, 14, 59, 31, 17, -12, -36, -9, -3, -6, -41, -7, 12, 4, 52, 10, 18, 28, 43, 33, 2, -10, 18, -14, 6, -16, -41, -19, 16, 1, 38, -39, 63, 5, 36, 18, -10, 31, 10, 9, -9, -32, -11, 1, 50, -3, 1, 11, 34, 14, 69, 16, -17, 38, 19, 78, 16, -29, -18, 16, 70, 3, -3, -4, -22, 18, 54, 29, -16, 1, -55, 14, -19, 2, -24, 11, 45, 7, 29, -29, -23, 27, 12, 22, -24, -19, -25, -31, -20, 14, -42, 2, 17, -24, 5, -33, -51, 12, 2, 6, 34, -82, -64, 38, -10, -12, -46, 19, 82, -1, 19, -56, 36, -9, 45, 18, 12, 2, 19, -45, 2, -32, -42, -18, -4, -2, -7, -54, 22, 6, 43, -38, -4, -45, -74, -43, 59, -39, 38, 58, 120, 3, -32, -33, -27, -15, 12, -16, 12, 21, -71, -12, 89, -53, 29, 46, 88, -22, -1, -27, -65, -59, 12, -30, 30, 1, -72, -21, 127, -30, -22, 15, 72, -1, -30, 49, -45, 2, 27, -51, 43, -88, -45, -45, 96, -30, -8, -3, 16, -4, 27, 14, -96, 16, -59, -7, 53, -79, -51, 1, 114, 15, -30, 26, -65, -37, 50, -1, -58, -33, -51, -22, 12, -128, -43, 7, 55, -15, -33, 14, -46, -27, -25, -22, -42, -16, -75, -15, 21, -75, 32, 7, 93, -25, -42, 2, 39, -7, -3, 3, -52, 21, -66, -49, 21, -39, -11, -16, 8, -10, -16, -7, 26, -44, -85, 4, -45, 1, -65, 11, 29, -65, -75, -25, 84, -7, 1, 1, -80, -12, -29, 93, 27, 14, 59, -51, 10, -65, -53, 1, 99, 3, 14, 45, -128, -2, 14, 45, 74, -33, 85, -2, 7, -43, -4, 4, 103, -15, -22, 38, -117, -25, -10, -27, -25, -12, 33, -21, 51, -115, -11, -27, 68, -72, -45, -4, -120, -8, -7, -70, -84, -2, 52, 1, 1, -95, 27, -12, 46, -42, -25, 22, -128, 15, -45, 8, -62, -2, 70, -3, 39, -71, 37, -38, -45, -14, -33, 27, -118, -22, -88, 58, -86, 1, 12, -11, 25, -95, -10, -14, -27, -3, 11, 12, -118, -33, -84, 26, -52, -7, -22, -16, 2, -75, -7, 12, -29, -7, -1, -1, 4, -33, -118, -14, -80, 11, -8, -27, 12, -95, 118, -26, 103, 7, -39, 4, -42, -12, 1, -120, 118, -42, 22, 4, 43, -93, 124, -16, 22, -2, 22, 12, -65, -15, -11, -69, 124, -8, 74, -11, 44, -69, 37, -32, 27, -3, 2, 7, -93, -14, 8, -32, -4, -11, 118, -50, 22, -51, 86, -14, -8, -65, -29, -2, -74, -1, 12, -10, -39, 22, 30, -2, 32, -66, 27, 8, -27, -62, -16, 33, -74, 7, -44, -32, -62, -22, 44, 4, 38, -62, 8, -10, -45, -21, -11, -22, -74, -1, -89, -111, -89, -27, -52, -14, 43, 7, 21, 10, -29, -39, -22, -3, -45, -21, -46, -128, -72, -3, -3, -7, -1, -51, 38, 11, -39, -1, 1, 32, -27, -22, -79, -128, -10, -15, -2, -29, 30, -79, 96, -2, 7, -2, -8, 25, 8, -12, -53, -125, 38, 12, 21, -2, 66, -124, 120, -29, 25, 1, -32, 42, 37, -11, -30, -128, 69, -15, 86, -52, 22, -124, -86, -21, 46, 3, -4, -14, -29, -3, -59, -128, -10, -27, 102, -33, 65, -95, -128, -3, 14, -45, -3, 4, -62, 14, -10, -110, 1, -44, 108, -12, 27, -69, 4, -12, 4, -66, -10, -1, -70, 3, -22, -59, -49, -2, 32, 1, 11, -26, -38, 8, -8, 3, -50, -11, 10, 2, -16, -86, -65, -26, -71, -8, 7, 16, 11, -30, 37, 1, -14, -14, -128, -16, -46, -16, -15, -11, -97, -10, 11, 14, 29, 15, 7, -15, -37, -39, 53, -16, -2, -128, -42, -15, 2, -30, 3, -115, 37, -33, 49, 1, -11, -33, -1, -11, -14, -84, -22, -7, 14, -22, 7, -96, 11, -15, 69, -37, -38, -33, 12, -14, -7, -109, -2, 11, 49, -7, 39, -103, -121, -7, 4, -15, -42, 11, 37, -8, -75, -128, -39, -37, 65, -32, 42, -30, -86, -3, 33, -44, -45, 16, -88, 10, -74, -101, -29, -3, 102, -22, 4, 12, -49, 30, 97, -8, -4, 2, -118, -27, -38, -128, -53, -22, 53, -12, 26, 38, 25, -30, 51, 3, -38, 25, -15, -10, -37, -101, -52, 4, -8, -37, 22, 43, 2, -1, 121, 12, -11, 11, -110, 12, 25, -72, -42, -46, -55, -3, 43, 75, 29, -37, -10, -21, -22, 2, -124, -21, 127, -4, -42, -22, -46, -3, 15, -79, -75, -4, 25, -26, -49, -12, -39, 2, 7, 27, -10, -7, 27, -12, 12, -127, -15, -11, 16, -39, -1, -22, -25, -39, -44, -46, -53, 10, -8, -22, 38, -128, 25, -21, 21, -37, -15, 32, -75, 2, -22, -65, -62, 3, 59, -42, 65, -80, -69, -33, 94, -39, -12, -3, -71, 4, -38, 12, -29, -8, 44, -16, 62, -33, -15, 4, 97, -45, -21, 10, -55, -4, -52, -66, -32, -32, 96, -50, 38, 37, -8, -21, 127, -4, 3, -2, 30, -15, -65, 1, -29, 16, 96, -25, 29, 59, -10, -11, 127, 3, -27, -16, 4, -25, -71, -12, -50, 11, -7, -16, 1, 58, 14, -10, -16, -3, -29, 3, 93, -25, 127, -65, -66, -21, -38, -50, 10, -93, -3, -37, 70, -12, -16, 11, -37, -42, -32, -72, 4, -45, 3, -45, 1, -58, -2, -10, 33, 1, -29, -22, -70, 14, 14, 3, -1, -37, 30, 11, -1, -79, -38, 7, 55, -44, 1, -25, -128, 3, -46, -59, -38, -21, 16, 4, 46, -89, -37, -26, 58, -59, 7, -7, -38, -33, -21, -128, -8, -1, 30, -12, 15, -74, 1, -10, 46, -16, 1, 22, -72, -39, -37, -7, 11, -1, 127, -26, 43, 38, 4, -16, 55, 1, 8, 21, 50, -25, -51, -33, -27, -7, 127, -14, 11, 58, -37, -15, 95, 2, -29, -37, -43, -32, -102, 72, -32, -29, 127, -30, 46, 21, 27, 11, 32, -4, -29, -21, -4, 3, 3, 38, -58, -7, 1, 1, -1, -10, -55, -1, 72, -16, -45, -39, 46, 29, -1, -49, -15, -25, -15, 14, -8, 2, 45, -7, 79, -1, -46, -15, 99, 7, -2, -11, -68, -22, 79, -55, 10, -38, 14, -1, 26, -39, -38, 4, 68, -21, 30, -53, -51, -8, 37, -37, -2, -96, -44, -2, 8, -14, -37, 10, -39, -27, -26, -66, 21, -27, 65, -44, 30, -88, -7, -25, -26, -14, 29, -22, 1, -27, -55, -85, 32, -4, 120, -50, 38, -8, 16, -3, 46, -1, 1, -3, 14, -21, -75, -8, -8, -10, 127, -30, 59, -32, 55, -2, 52, -15, -7, -16, 38, 8, -117, 49, -53, -49, 127, -16, 43, 7, 44, -44, 25, -11, -44, -42, 127, -37, -38, 80, -71, -2, 51, -46, 3, 3, -49, -1, 72, 2, -2, 29, 72, -12, -38, 118, 50, 1, 45, -12, 30, -8, -53, -44, 102, 15, 12, -14, 114, -30, -7, 37, 15, 10, 68, 10, 3, -80, -50, -21, 85, 3, -29, 12, 59, -37, 11, -52, -38, -26, 33, -25, -37, -29, -70, -16, 32, -7, -12, -15, 14, -4, 15, -51, -33, -52, -25, 8, 12, -44, -27, -4, -25, -12, -16, 1, 26, -30, 53, -66, 14, 8, 29, -38, 26, -8, 55, -7, 26, -12, -3, 25, 43, -25, 21, -21, 27, -22, 127, -62, 21, -21, 43, -7, 44, -39, -37, -3, 69, -42, -65, 99, -37, -14, 127, -43, 58, 51, 14, -38, 74, 8, -22, -16, 101, -10, -22, 84, -95, -38, 27, -25, -8, -26, 30, -25, 94, 11, 7, -29, 51, 1, 29, 85, -68, -43, 45, -39, 21, -10, -2, -8, 117, 7, 16, 4, 16, -39, -8, 80, -26, -33, 39, -43, -42, -32, -25, 1, 46, -7, 11, 29, 16, -8, -25, 55, -101, -8, 39, -58, 8, -75, -59, 2, 74, 29, -21, -16, -32, -29, -8, -42, -16, 11, -32, -26, 43, -97, -21, -11, 37, -29, -21, 11, -15, -58, -3, -66, -7, -30, -21, -43, 37, -95, 70, -14, 44, -38, -14, 8, -33, -80, 29, -85, 10, -11, 111, -62, 30, -32, 46, -10, 51, -1, 12, 29, -53, -51, -39, 14, -3, 7, 127, 11, 1, 12, 1, -14, 96, -32, -21, -4, -45, -16, -70, 52, -58, -15, 88, -42, 4, -42, 52, -50, 66, 2, -22, -7, -55, -8, 1, 38, 93, -52, 39, -51, 8, -55, 8, -38, 93, -27, -22, -4, -1, 14, -11, 86, 96, -42, 93, -37, 44, -3, 51, -51, 53, -39, -30, 4, -27, -37, 4, 51, -44, -1, 108, -32, 26, -44, -14, 3, -29, -4, 4, -12, -26, -14, -15, 32, -44, -51, 71, -62, 39, -103, 39, -26, -51, -1, -33, 10, -62, -11, -21, -121, -49, -44, 70, 7, 50, -96, 29, 1, 33, -10, -1, -2, -7, -30, -15, -99, -29, 3, 111, -26, 25, -99, 44, 1, 8, -65, -21, -65, -49, 2, -1, -71, 26, -26, 127, -53, 37, -46, 43, 2, 4, -49, -12, 29, -65, -43, -85, 59, -88, -38, 127, 8, 22, -39, 71, -32, 33, -49, -10, -2, 26, 12, 14, -15, 38, 22, 68, -4, 7, -43, 59, -7, 38, -55, -37, -11, -4, -1, -14, 50, 59, 1, 89, -21, 38, 1, 127, -50, -10, -4, 8, -32, 7, 4, 1, 71, 21, 1, 124, -12, 26, -38, -44, -26, -14, -29, -12, 45, 22, 4, -7, 80, -101, -2, 72, -33, 8, -75, -44, -43, 1, 7, -72, 71, 12, 8, -2, -1, -75, -27, 22, -65, 10, -109, 72, -15, -14, -44, -45, 14, -49, -30, -10, -128, -30, -26, 109, 4, 1, -115, 42, 21, 12, -49, -30, -2, -52, -12, 15, -110, -14, -49, 89, -44, 49, -29, 8, -15, -21, -69, -75, -16, -14, -2, -66, -128, -74, -43, 118, 43, 74, -68, -69, 5, 3, -19, 29, 24, 75, -46, -68, 24, 69, -22, 46, -63, 127, 127, 83, -4, -18, -85, -11, 115, -39, -48, -101, 17, -96, -83, 62, -53, 20, -68, 19, -114, 122, -128, -68, -62, -37, -19, -90, -2, -60, -59, -37, -128, 40, -1, 24, 23, 105, -75, -49, 111, -31, 12, -83, 38, -96, -108, 52, -94, 41, 99, -5, 22, 18, -29, -14, -2, -48, 5, -128, -1, -84, -36, -38, -38, 6, 16, 60, 14, 75, -62, -90, -8, -11, 58, -101, 37, 24, -121, -76, -80, 127, 40, 62, -37, -16, -5, -3, 23, -60, -13, -55, -11, -32, -1, -54, -107, 82, -93, -84, -5, -8, -74, -17, 23, 127, -23, 53, -53, -87, -19, 38, -26, -53, -94, -59, 2, 31, -128, -64, 99, 127, -115, -75, -91, -84, 11, -85, -105, 42, -24, -32, -52, -32, -84, 34, 85, 3, -71, -29, 24, -115, -3, -64, 30, 103, -119, 41, -5, -9, -55, -54, 36, 75, -27, -34, 12, -87, 17, -27, -72, 52, -128, 18, 1, 49, -94, -45, 2, 59, -59, -66, 12, -23, 36, -53, -39, 98, -87, -19, -75, 23, -24, 13, -122, 31, -48, -64, -93, -71, -48, -59, -89, 127, -62, 59, 4, 11, -43, -48, 26, -14, -112, -38, 48, -8, -71, -16, -128, 59, 3, 13, -89, -17, -20, -24, -3, -11, -47, -74, 71, -30, -42, 11, -29, 30, 38, 76, -71, 41, -46, -60, -32, -94, -39, 2, 14, -89, -31, 43, -114, -26, -78, 40, -32, -53, -7, -87, 74, 99, -37, -102, -47, 22, -17, -60, 5, 72, 32, 80, -9, 69, -106, -38, 69, 127, -90, -45, 16, 78, 4, -108, 12, 8, -55, 76, -32, -63, -95, 55, 34, 8, 4, -24, 29, -69, 7, -22, -55, 43, -62, -26, -67, -24, -93, -6, -58, -49, -63, -39, -2, -11, -6, -99, -58, 49, -110, -90, -38, -6, -34, 59, 22, 83, -30, -47, 8, -67, -96, 37, -18, 90, -16, 36, -42, 46, -63, 8, 22, 30, -99, -128, -55, -24, -7, 27, -40, 127, -41, 71, -74, -14, -68, -67, 55, -8, -43, -128, -75, -76, -54, 127, -66, 71, -76, -5, -76, 127, -76, -125, -27, -13, -90, -71, -31, -78, 11, -11, -53, -114, -18, 13, -74, -22, -63, 37, 27, -11, -26, -89, 1, -64, -42, 101, -20, 64, -90, 127, 29, 29, -78, -48, 60, -128, -128, -24, -37, 8, 23, 34, -14, 40, -89, 99, -74, 62, -26, -46, 32, -55, -112, -32, 17, -41, -20, -11, -72, 108, -54, -83, 23, 89, -67, -23, -78, 3, -78, -34, -19, 1, 16, -55, -128, 79, -124, -71, -72, -39, -14, 68, 5, -45, -64, -128, -2, -14, -84, -6, -112, 32, -91, -84, -18, 11, -22, -54, 22, 24, -22, -72, -39, -9, -41, 11, -34, 47, -98, -102, -18, -11, 20, 43, -43, 43, -117, -82, -53, -9, -58, 60, -36, 22, -1, -59, -67, 106, -80, -41, 24, -58, -52, -106, 19, -13, 16, -40, -128, -105, -89, 23, -119, 17, -98, -82, -58, -87, -34, -84, 49, 3, -31, 124, -121, 22, -121, -84, 1, -58, -102, -60, 127, -98, -12, -18, -76, -103, -24, 127, -89, 34, -128, -80, -30, 7, -108, -78, 67, -53, -119, -22, -37, -102, -20, 30, -80, -11, -98, -83, -29, 75, 6, -24, 23, 19, -58, 9, -78, -20, -1, -101, -39, 99, -85, 1, -4, 42, -5, 24, -74, 4, -5, -11, 1, -6, -75, 119, -4, 76, -82, -93, 12, 4, -45, 20, -1, 93, -69, -52, -8, 72, -122, 82, -107, 127, -37, 13, -34, 38, -74, -26, 1, -16, 5, -85, 3, -41, -16, 58, -42, 47, -46, -82, 14, 103, -67, -98, 2, -24, -16, -107, 22, 55, -103, -36, -128, -87, -39, 62, -30, -55, -128, -24, -76, 110, 9, -128, 90, -13, -53, 84, -120, -69, 46, -36, 5, 66, 58, -128, -20, 99, -24, -115, -76, -39, -6, 127, -76, 53, -93, 85, -45, -31, -16, -128, 4, 8, -20, -53, 29, -46, 63, -3, -127, 9, -118, 48, -18, 52, -36, -102, -29, -24, -79, 12, 26, -14, 30, -9, 9, 53, -72, 48, -111, -2, -126, -40, 41, -84, 55, -9, 14, -18, -37, -68, -43, 83, -75, 105, -27, 32, -64, -108, -32, 59, -6, 3, 12, 18, -12, 63, -75, 19, -121, -41, 20, -14, -128, -53, -7, -20, -74, -91, -38, -7, -115, 127, -47, 41, -7, -128, -99, 84, -128, 11, 5, -18, 16, -12, -48, -26, -16, 22, -39, 72, -76, -7, 4, 24, -4, -3, 41, 53, -108, -76, 29, -46, 3, -58, -74, -93, -20, -94, -14, 27, -30, -52, 117, 84, -68, -128, 72, 5, -79, 22, -60, -74, -12, -69, -8, 12, -91, -17, -37, 127, -54, -106, -3, -99, -83, -128, -3, 64, -67, -2, -46, 69, 30, -46, -53, 39, -8, -74, 38, 8, -99, -128, -89, 53, -47, 87, -37, -2, -5, -68, 3, 22, -16, -68, -5, -78, 34, -23, -24, 14, -58, 71, -58, 5, -27, -18, 16, 8, -95, -108, 45, 29, 34, -108, -112, 68, -128, 115, -49, 62, -24, 7, 31, 68, 29, -36, 40, 16, -39, 63, -90, 39, 42, 29, -112, -3, -106, -38, -75, -24, 48, -59, -5, 20, 24, -13, 12, 63, -49, 22, 34, 90, -18, 76, 75, 59, 7, -39, 90, -23, -45, 30, -82, 97, -63, 11, -12, -27, 48, 19, 46, 72, -27, -55, 55, -23, -38, -12, -24, 63, -63, 85, 76, 66, -84, 30, -59, 89, -30, -69, 62, -99, -87, 1, -42, 14, -105, -128, -67, -23, 22, -79, -84, -8, -94, -46, 36, -126, -8, -71, -83, 93, -36, 127, -37, -1, -26, -60, -26, -14, -85, -128, 4, -106, -29, 11, -93, 55, -59, -3, -72, 5, -17, -22, 46, -1, -91, -128, 11, 24, -24, -89, -54, 29, -91, -90, -58, 6, -49, -39, 31, 23, -72, -94, -72, 38, -43, 121, -24, 112, -72, 76, -76, 64, 30, -1, 46, 42, 6, -83, -37, 34, 27, -43, -74, 69, -128, 127, -58, 19, -43, -55, 38, 12, -66, 7, 85, 12, -62, 98, -91, -3, -49, 95, -27, -49, -9, -66, -8, -128, -31, 3, -20, -91, -72, 22, -97, 42, -128, -128, -27, 16, -59, -17, 32, 95, -27, 1, 1, -2, -34, 20, -22, 125, -52, -124, 27, -128, -40, -62, 19, 93, -17, -43, 82, -128, -55, -71, -76, 19, -41, 68, -11, -30, 6, -36, -23, 55, -17, -18, -19, -72, -49, -60, -97, 85, -16, 99, -45, 67, 2, -27, 36, 34, -105, -46, -24, -62, -29, 48, -29, 103, -74, 85, -110, -29, 34, -9, 43, -52, -84, -128, -62, -59, 22, 46, -53, 34, -1, -128, -43, -52, -105, -1, 23, 7, -83, -60, 52, -110, -45, -45, -54, -19, -2, -42, 37, 76, -48, -63, -46, -119, -20, -93, -59, -18, 46, 75, -106, -128, -8, 45, -20, -23, -32, -26, 38, -76, -69, 27, 1, -7, -23, 103, -42, -23, -128, -20, -89, -18, -122, -59, 24, -78, -1, -29, 91, -103, -66, 64, -67, -79, 7, -85, -58, -22, -45, 17, -2, 75, -1, -48, -2, -72, -49, -24, -64, 78, -54, -118, 23, -2, -36, -17, 8, -128, -17, 1, -16, -40, -24, -125, 19, -125, -6, -67, 37, 24, -48, -23, 4, -94, 6, -110, -48, -63, -4, 7, -59, 95, -9, -37, -85, 14, 7, -72, 22, 38, -30, -74, -18, -47, -24, -32, -97, 125, 6, 12, 20, 112, -82, -79, -31, 13, -29, -24, -19, -27, 14, -30, 17, -42, 19, 20, 34, 93, -79, -58, 9, 108, -59, -8, 55, -62, -90, 93, -95, -19, -63, 8, -17, -12, 23, -49, -91, 127, -99, -40, 83, -4, 67, -31, -40, -96, -71, -111, 34, 46, -99, 5, 11, -99, -67, 53, 64, -76, -105, -124, -3, -24, 17, 79, 1, -54, -71, -4, 68, -26, -18, -34, -128, -118, -12, -106, -126, -3, 1, 72, -38, -60, -40, -85, 37, -52, -5, 14, 16, -110, -22, -58, -83, 54, -13, 54, -12, 2, -49, -90, 18, -125, -102, -1, -1, -124, -41, 84, -128, 79, -102, 39, -41, -20, -68, 27, -43, 125, -118, 48, -26, 7, 5, -59, -96, 29, -19, 63, -64, 19, -8, 38, 43, 39, -6, 27, -24, -30, -41, 26, -127, 8, 14, -34, -3, 47, -14, -52, -26, 79, 1, -83, 54, 27, 127, -1, -39, -19, 30, 96, 32, 13, -76, -72, 45, 63, 24, -85, 6, 76, -18, -1, -128, 1, -3, 54, 30, 63, -22, 18, -37, -96, 34, -29, 29, -91, -19, -14, -128, 87, -20, 52, 52, 87, -36, -55, -13, -62, -27, -75, 1, -74, -24, -32, 8, 95, -68, 17, 20, 64, 18, -117, 54, -71, -126, 23, -30, -62, 45, 24, -128, 23, -80, 48, -14, 27, -41, -42, 8, -84, -45, -94, 29, -95, 34, -13, -125, 30, -54, 101, -17, 87, 1, -80, -23, -8, -5, -74, 108, 18, -31, 30, -118, -11, -29, 76, -79, 99, 6, -58, 6, -53, -124, -47, 2, -40, -23, 49, -32, -95, -7, -72, -23, -2, -36, -72, -72, -14, -124, -97, 87, -27, -101, -89, -113, -89, 18, 27, 20, 89, 5, -33, -75, 22, -27, -60, 33, -121, 30, 41, -56, 9, -13, -6, -65, -100, -10, -15, -4, 51, -60, 11, 15, -62, -100, 24, -25, -106, 19, -25, -69, -7, 66, -90, -103, 102, -121, -12, 27, -29, -73, 47, -121, -46, -19, -26, -84, -2, 60, -51, -58, -29, -55, 1, 33, -19, -106, 16, -7, 3, 107, -15, -104, 20, 13, -8, -111, 115, -42, -41, -32, -80, -128, 67, 47, -43, -47, -44, -96, -42, 27, -111, -104, 49, -87, -5, -22, -121, -79, -128, -128, -71, -42, -18, -11, -29, -33, -16, -22, -48, 1, -55, -29, -29, -28, 62, -37, -127, -14, 34, -9, 4, -86, -73, 8, 32, 37, 2, -60, -56, -125, -62, -71, -44, 13, 51, -89, -16, 86, -73, -26, -13, 8, -104, 25, 22, -72, -11, -69, -82, 6, 90, -97, -34, 4, -78, 73, 52, -97, -128, 12, -77, 15, -44, -103, -89, -15, 26, -128, 11, -28, -53, -1, 69, -83, -47, -27, -121, -27, -64, -52, 1, -60, -22, -92, 45, 46, -112, -83, -128, -128, -77, -81, -56, -78, 3, -86, -51, 46, 25, -17, 1, 67, 4, 12, -79, -81, -84, -15, -71, -128, -25, -69, -13, -81, 27, -66, -48, 25, -73, 17, -128, -6, -128, -78, -67, -39, -72, -102, -20, -52, -128, -94, 36, 4, -82, -62, -43, -128, -5, -1, -37, -48, 10, -81, 77, 42, -102, -1, 11, -49, -85, -114, -52, -37, -128, 58, -1, -19, -81, -72, 4, -17, -8, -121, 29, -66, -117, -66, -82, -82, -64, 4, -78, -73, 18, -62, -58, 27, -81, -66, -34, -20, -67, 43, 73, -84, -45, -1, -24, -44, -17, -47, -3, -32, -85, -78, -1, -48, -128, 41, 78, -81, -4, 32, -32, -118, -29, -77, -32, -43, -107, -1, -27, -67, -82, -8, 23, -5, -44, -46, -9, -24, 3, -75, -128, 47, -79, 17, -6, -67, -47, -2, -60, -96, -43, 65, -42, -128, -10, 7, -64, -55, -37, -32, 56, -62, -57, -43, -35, -104, -66, 51, -66, -36, -27, -46, -128, -15, -112, -43, 67, -60, -40, 26, 47, -16, -10, 1, -114, -91, 66, -51, -33, -9, -104, -58, -20, -62, -79, -26, -17, 95, -74, 124, -1, -5, -52, -67, -40, 13, -128, -14, -48, -121, -20, 97, -107, -126, -65, 17, -40, -26, 57, 11, -107, -18, -124, -117, 5, -42, -64, 13, -23, -108, -48, 26, -89, -112, 53, 81, -36, -23, -17, -44, 86, -119, -78, -53, 16, -42, -16, 83, -81, -44, 53, 32, -60, 60, -128, -128, 12, -117, -81, -58, -65, -67, -34, -62, -40, -92, 89, -5, -97, 24, -24, -97, -29, -17, -128, 16, -8, 8, -24, -30, -79, -118, -4, -56, -74, -82, -47, -72, 77, -39, -98, 69, -52, -10, -5, 1, -113, -52, 29, -51, -77, -128, 11, -83, 28, -96, -49, 26, 10, 28, 10, -20, -12, -97, -2, 75, -78, -65, -18, -13, -43, -74, -101, -20, -100, -60, -3, -65, -25, -79, -16, -115, -67, 18, -60, -128, -28, -24, -24, 4, -40, -78, -125, -28, -35, -20, -60, 62, -49, 49, -89, -128, 16, -98, -52, 19, -29, -118, -92, 2, 18, -76, 72, -2, -56, -1, -11, -102, -8, -128, -92, 20, -87, -67, -96, 65, 7, -19, 64, 2, -110, 5, -53, -47, 76, -128, -128, -47, -34, -102, -45, 19, -74, -85, 66, 18, -128, -83, -113, -94, -22, -37, -128, -39, -81, -33, 2, -40, -86, -47, -27, -55, -43, -89, 127, -128, 82, 10, -37, -27, -32, 5, -7, 3, -82, -20, 35, 23, -85, -77, -128, -58, -5, -126, -90, 8, 15, 10, -33, 35, -36, -47, -25, -62, -97, -33, 27, -52, -85, -40, -92, -55, -89, 117, -89, -102, 44, -103, 4, -64, -92, 52, -113, -128, 43, -36, -97, -6, 56, -112, -32, -12, 3, -53, -11, 127, -106, -17, -110, -67, -17, 3, -56, -6, 74, -96, -102, -81, -86, 3, 75, 15, -128, -48, -46, -13, -26, -60, -100, -57, -107, -28, -56, -9, 81, -111, -24, 13, -128, 9, -45, -42, 52, -82, -51, 28, -30, -128, -128, 15, -2, -80, 7, -1, -48, -4, 13, -36, 34, -86, -128, 24, -33, -98, -26, -29, -53, -23, 55, -10, -128, -102, -96, -7, 1, -98, -91, -1, -14, -12, -37, 11, -20, -15, 57, 39, -39, -47, -78, -128, 32, -58, -109, -40, 30, -65, -34, -24, 18, -17, -128, 46, 127, -17, -62, -111, 4, -114, -53, 32, -67, 47, -118, 57, 11, -128, -75, -128, -39, 16, 100, -49, 2, -92, -16, 49, 65, -55, -75, 39, -69, -71, 15, -24, -92, -112, -107, -39, -30, -15, -128, 49, -106, -95, -127, 3, -9, -42, 17, -2, -71, -80, -51, -69, 14, -6, -60, 17, -24, -72, -95, -10, 45, 1, 35, -36, -73, -10, -51, -39, -79, -98, -10, 77, 14, -49, -89, -8, -53, -36, -14, -48, -20, 19, -9, -125, -13, -92, -52, 15, 3, -109, -80, -13, -42, -72, -12, 23, -37, -57, -48, -84, -49, -74, -18, -20, 36, -128, -106, -24, -125, -49, 6, -27, -69, 4, -128, -58, 12, -60, -103, -34, -6, -28, -4, 81, -102, -128, -12, -53, -1, -41, -39, -44, 80, -25, -18, 22, -6, -73, -18, 73, -8, -69, -46, -90, -95, -13, -57, -124, 28, -80, -5, 17, -128, -74, -36, 20, 33, -101, -22, 87, -115, -73, -110, -77, -56, -80, -58, 5, -74, 5, -35, -18, 81, -94, 37, -75, -76, 42, -85, -6, -24, -10, -37, -34, 89, -40, -65, 52, -16, -121, -10, -16, 1, 51, -9, -56, 6, -56, -15, 35, -1, -41, -30, 77, -44, -42, 4, -29, -4, -2, -24, -86, -78, -87, -29, 64, 11, -98, -128, -4, -33, -111, -32, -17, -10, -60, -91, -14, 23, -15, -128, 30, 16, -41, -125, 11, -82, -85, -84, -46, -42, -84, -86, -96, 20, -110, -80, 29, 5, 94, -69, -15, -107, 3, -56, 4, -55, -2, -25, -128, -5, -97, -56, 121, -55, 62, -128, -121, -34, -90, -22, -76, -56, 37, -109, -67, -1, -119, -42, 30, -65, -32, -42, -66, 74, -77, -5, -32, -100, -22, -71, -90, -100, -66, -30, -65, -14, -52, -111, -36, -22, -74, 81, 24, -94, 12, -91, -33, -26, -77, -82, 41, -67, -86, -60, -17, -44, -22, 6, 34, -83, -49, -45, -65, -5, -42, -86, 13, -74, -23, -119, -74, -128, -77, -7, 35, -79, 42, -28, -40, 75, -58, -110, 75, -2, 74, -128, 32, -43, -27, -51, -3, -125, 36, -75, -112, -25, -109, -6, -28, -41, -42, -67, 45, -28, -58, 83, 42, -108, -115, -65, -85, 1, -87, -103, -45, -64, 60, -128, -1, -28, -8, -19, -78, 7, 20, -34, -7, 42, -101, 127, 51, 1, -29, -95, 40, 86, -65, 127, 14, -51, -7, -64, -20, -60, 8, -60, -40, -123, -81, -94, 11, 35, -100, -8, -53, -71, 24, 110, 1, -44, -55, -96, 8, -98, -104, -37, 16, -23, -73, -36, -65, -113, 8, -92, -101, -11, -73, -42, 40, -23, -83, -92, -44, 45, -65, 11, 3, -62, -24, -26, -22, 51, -17, -43, -58, 39, -108, -34, 1, -49, -92, 12, -15, -24, -42, -92, -15, 42, -118, -104, -81, -67, -37, -69, 10, -49, -10, -60, -69, -75, 108, -74, -41, 11, -92, 14, 29, 85, -49, -19, -1, -77, -47, 60, -62, -20, -72, -115, -103, -84, -128, -65, 29, -18, -83, -14, 39, -32, -43, -49, -46, -65, 48, 6, -51, 15, -58, -53, -17, -26, -43, -60, 127, -72, -71, 39, -34, -24, -107, -118, -35, 75, -29, -43, 40, -111, -48, -56, 87, 16, -92, 64, 42, -12, -41, -18, -60, -52, 3, -45, -5, -56, -79, -30, 60, 69, -12, -86, 41, 2, -46, -25, -82, -62, -111, -128, 25, -90, 13, -92, -16, -11, -71, 1, -71, -127, -28, -55, -108, -56, -65, -71, -23, -9, -72, -65, -34, -81, -56, -9, -13, -128, -87, -96, -48, 20, -76, -86, -15, -82, -2, -87, -46, -96, 5, 10, -15, -111, -65, -6, -121, -7, -128, 5, 57, -37, -25, -32, 127, -118, -27, -62, -9, -72, -125, -2, -40, -29, -75, -115, 46, -2, -37, -128, -83, -80, -73, -18, 12, -15, -60, -11, -60, -128, -27, -90, 22, -90, -128, -12, -115, -2, -60, 41, -28, 45, 42, -95, -32, -48, -42, 46, -11, 2, -60, -66, 127, -4, -69, 3, 5, -55, -126, -128, -62, 24, -40, -25, -20, -128, 7, -128, 53, -2, -128, -10, -34, -8, -18, -16, -91, 41, -107, -76, 19, -92, -128, -72, 83, -15, -53, -33, -17, -46, -26, -92, -110, 49, -86, 11, -15, -97, 15, -10, -77, 20, -109, -76, -65, -111, -89, -46, -91, -81, -78, -57, -34, -119, -128, -115, -7, -49, -46, -11, -30, -39, 1, -15, -18, -39, -32, -20, -43, -124, -52, -80, 16, -126, -76, -32, -104, -41, -22, -102, -44, 51, 20, -32, -13, 22, -32, -64, 102, -15, 5, -47, 55, -24, 11, -21, 84, 29, 119, 113, 67, 33, -55, -8, 8, -22, -1, -114, 127, -8, 35, -47, -126, -52, 14, 42, 116, -43, 97, -40, -96, -41, -50, -112, -128, -78, 13, 25, 90, 17, 80, 97, -37, 21, -24, -128, -14, 67, 87, -71, -91, -70, 42, -56, 37, -49, -55, -111, -64, 110, -3, -22, -65, -8, -24, -128, 59, -128, 37, 5, 65, 1, 24, -50, -76, 36, 47, -96, 18, 127, -85, 30, 15, -70, 62, 2, -73, 43, -28, -77, -50, 104, 50, -73, -64, 15, -86, -16, -6, 8, -41, 45, -46, -57, 37, -15, -104, -87, 83, -83, 24, -128, -40, -84, 127, -107, 13, -83, -18, -92, -10, -99, -50, -124, 31, 12, 13, -60, 44, -102, -46, -27, 1, -4, -83, -27, -16, 127, 27, -8, -48, 127, 66, 11, -4, -99, -71, 64, -7, -44, -41, 10, 47, 78, 107, -57, -37, 31, 59, 43, -12, -17, -78, -61, 73, 29, 104, -47, -67, 124, 85, -41, -77, -8, -14, -42, -128, 17, 5, 33, -17, -48, 61, 29, 28, 127, -128, -56, -40, -90, 25, -28, -77, 6, 91, -99, 52, 2, -34, -31, 28, 1, -66, 71, -43, -126, 20, -13, -95, -72, -71, -66, -93, -75, -33, 36, 34, -90, 67, -102, -43, -59, -79, -104, -102, 30, -86, -118, 3, 77, -17, -34, -84, -76, 37, -128, 28, -62, 2, -86, -115, -44, -112, -87, -57, -68, -90, 80, 60, -112, 62, -128, -18, 71, -25, 42, 120, -8, 52, -6, -67, -96, -73, -11, -38, -91, 127, -109, 104, -75, 4, -6, 119, -10, 8, 85, -12, -42, -62, 44, -128, 66, -126, -87, -92, 29, 3, 48, -126, 52, -56, 68, 25, -84, -128, 20, -128, 67, 13, 127, -38, 49, 1, -7, -119, -13, -61, 127, -24, -82, -2, 59, 16, 88, -35, -128, 82, -50, -10, 11, -102, 28, -47, 72, 127, -64, 100, -15, -46, -3, -8, 2, 115, -67, -4, -89, -128, 66, -55, -42, -95, -8, 127, 80, 21, 66, -43, -28, -27, -111, 17, -60, 77, -21, -79, -16, 49, -94, -24, -13, 4, -3, 31, 14, -20, -128, 1, 87, -54, -2, 45, -70, 80, -75, -57, -48, 71, -77, -77, 48, 101, -65, 31, -46, -31, -30, 127, 57, 57, 19, -41, 35, -99, 89, -44, -91, -26, -17, -9, -2, 19, -62, 93, 68, 44, 127, 36, 38, -107, 127, -53, -108, 92, 116, 46, 24, -76, 28, 91, 97, 25, -88, -128, -2, -56, 71, -30, 57, 18, 13, 45, -112, 72, 53, -17, 104, -55, -5, 34, -20, -86, -29, 47, 84, -114, -57, 12, 118, 73, -10, 30, 94, 42, 53, -92, -5, -128, 70, -43, -28, -52, 52, 3, 31, -114, -1, 42, 16, -26, -29, -29, -30, -5, 48, -75, -67, -108, -48, 20, 10, -55, 19, 80, -22, -31, -30, -84, -6, -100, -70, -67, -21, 55, 44, 40, 24, -127, 5, 20, -47, -83, -22, -71, 2, 5, -57, 2, 48, -15, 28, -29, -33, -85, 15, -76, -7, 48, -110, 45, -59, -24, 60, -104, -106, -43, -4, -102, 10, -60, -22, -92, -48, 79, -8, 25, -13, -93, -110, -67, 8, 1, -83, -15, -11, 70, 1, -72, 102, 15, -66, 46, 42, -25, -64, -35, -14, -113, -55, -14, 7, -43, 76, -16, -107, 61, -53, -62, -26, -115, 34, -21, -50, -48, -7, -21, 47, -38, -21, 19, 41, -52, 47, -36, 38, -33, 95, -3, -10, -50, -88, 33, 10, -41, -9, 14, 104, 11, -79, -96, 11, -86, 127, -6, 22, 1, -94, -65, -41, -19, -66, -68, -126, 6, -1, -48, 35, -62, 37, -14, -61, -126, -126, -46, 44, -33, -65, -28, -55, 89, -50, -84, 12, -9, -91, -1, 1, -37, 34, -28, -85, -45, 9, 3, -106, 68, -101, -75, -96, -128, 3, -128, 5, -66, 72, -16, -73, -73, -14, -43, -61, 8, -52, 37, -24, -54, 56, -1, -70, -83, 66, 29, 25, -34, -1, -14, -75, 62, -65, 76, 9, -112, -100, 42, -16, 77, -128, -56, 21, 118, -17, 79, -3, 6, -113, 75, 35, -16, 11, -5, 44, -28, -104, -2, -56, -35, 5, -65, 122, 26, -80, 41, 4, -116, -22, -27, -67, -128, -70, -52, 72, -87, -15, 20, -75, 20, 47, -65, -13, -62, 11, 72, 15, -60, -14, -35, 7, -90, -2, -29, -127, 82, 48, -67, -44, -31, -90, -7, 21, -104, -19, -24, 45, -14, -33, -15, -52, 119, -83, -128, -16, 9, -120, 1, -48, -84, -13, 33, -95, -10, -67, -68, 99, 27, 84, -27, -79, -30, 40, 1, -48, -72, 40, -112, -34, -16, 33, 12, -2, 31, -92, 50, -45, -102, 127, -27, -89, 28, 55, 34, -52, 41, 20, -68, -21, -71, -34, 108, -28, -36, 99, -59, 95, -75, -7, -29, -34, 67, -16, 43, -45, -73, -84, 110, -10, -65, 86, 8, 53, -30, -42, -48, -38, -9, 59, -67, 127, 9, -50, 56, -4, 25, 52, 30, 14, 61, -98, -14, -7, -75, 34, 6, -127, -45, -12, -4, 11, 87, 60, 14, -16, 18, -9, 3, 60, -100, 26, -24, -48, -87, -128, -88, 7, -27, -11, 45, 70, 7, 38, -28, -7, -61, 8, 12, -36, 127, -62, -29, 41, -88, -85, 52, -52, -12, 15, 14, -64, -128, 29, 64, -27, -40, 62, -68, -112, -73, 72, -28, -34, -64, 91, 65, -26, 127, 11, 41, -112, -10, -48, 126, -45, -22, 107, -1, -16, -108, 15, -8, -14, -12, -36, -84, 50, -46, -18, 16, 9, -104, 3, 31, -60, 77, 45, 10, -40, 56, -54, 7, -56, 15, -73, 126, -14, -77, 113, 9, -30, -79, -50, -9, -11, 6, 33, 26, 20, -8, -52, 127, -6, -27, -108, -14, 53, 35, -97, 5, -104, -65, 25, 29, 56, 15, -76, 113, -34, 86, 41, 33, -24, 30, -128, -7, 100, -128, -28, 19, -128, 3, 27, -28, 19, -16, -22, 33, -14, -128, -18, 5, 61, -80, -71, -10, -13, -70, -78, -104, -57, 85, -50, 64, 9, -68, 107, -60, -44, -78, -50, 46, 41, -36, -50, -47, 13, 53, -84, -98, -67, -126, 7, 108, 57, 42, -40, 34, -13, 27, 47, 38, -15, 44, -43, -76, -22, -52, 127, -1, -14, 78, -1, 13, -29, 56, -59, 75, -36, -16, -57, 52, -24, -1, 127, -28, -26, 83, 60, 33, -54, -56, 91, 77, -67, -128, -94, 11, -55, -117, 47, -77, 4, 11, -68, 2, 62, 71, 46, 34, -31, -43, 73, -7, -94, 65, 35, -75, -54, -8, -31, -11, 28, 21, -73, 59, 55, -33, -1, 28, 71, -34, -117, -8, -34, -68, -18, -52, -20, -122, 17, -4, 71, -102, -21, 7, 13, -128, -108, 40, -85, -38, 78, -41, -24, -82, 14, -43, -52, -19, -102, 18, -34, -26, -53, -34, 9, -36, -46, -29, 56, 13, 17, 42, 17, 84, -102, -27, -43, 43, 84, -116, 24, 80, 72, -73, -77, -3, 66, 9, -49, 106, -85, 53, 79, -90, -82, 29, 35, 8, 1, 28, -110, -22, -34, 79, -5, 57, -71, -27, -82, -102, -9, -22, -64, 49, -52, 15, -37, -2, 65, 27, -18, 127, -45, 66, 1, -9, -15, -38, 53, 107, 5, -17, -53, -59, 44, -35, 12, -114, 94, -3, -17, -67, 82, -28, -37, -55, 40, 62, 127, -9, -93, 16, -48, -56, 110, -19, -30, 3, -72, 44, -128, -92, 13, 19, -20, -8, -128, -43, -28, -98, -120, 25, -76, 84, -89, 38, -78, -65, 59, -16, -45, 76, -75, -114, -3, -30, -36, 16, -15, -33, -9, -38, -86, -27, -128, 20, -49, -30, -12, 33, -128, 9, -45, -6, 16, -86, -27, -88, 1, 104, 28, -73, -64, -27, -102, 7, 10, 25, -64, -25, 13, -107, -50, -47, -18, 80, 24, 45, -47, -94, 104, 84, -73, 50, -107, -35, -64, -82, -57, -57, -1, 37, -31, -4, 56, -11, 84, 95, -68, 95, -29, -37, -102, -53, 67, -48, 68, 25, -4, -36, 67, -87, 112, 53, -113, -65, 53, 37, -68, -60, 86, -26, 114, 9, -5, 75, 26, 100, 33, -16, -41, -2, -40, -22, -31, -47, 49, -43, 16, -33, 35, -31, 95, -66, -73, 124, 22, -33, 11, 52, -99, 72, 72, 76, 127, -64, 66, -40, -91, 17, 13, -61, 14, -117, -6, -1, 13, -12, -101, 59, -49, -37, -128, 47, -52, -114, -57, 127, 49, 79, 72, -6, 48, 93, 14, -109, 15, 29, 24, -67, -26, -102, 49, 42, -80, 43, 67, -10, 96, -95, 127, -94, -6, 80, -16, 53, 108, -67, 73, 70, -49, 87, -15, 7, 70, -29, -55, -80, -7, 20, -77, 34, 36, -7, -102, 34, 85, -11, 80, -2, -4, -49, -80, 34, -10, 72, 5, -56, 80, 61, 62, 14, 20, -84, 29, -22, -13, -113, -11, -21, -57, 127, 9, -59, 127, -79, 87, -59, -14, -67, 18, -22, 17, -46, -5, 27, -98, -47, -31, 6, -86, -42, -72, -61, -16, -109, 75, -64, 76, 30, -98, 19, 73, -10, -4, -64, -128, 127, -110, -44, 4, -64, -3, 4, -16, 89, 44, 10, -29, -85, -20, 24, 35, -28, 20, 16, -30, 9, 10, 17, -5, 8, -36, -35, -24, 28, -7, 44, 33, -85, 1, 20, -52, 5, 3, 7, -16, -3, -28, -6, 20, 26, -16, 45, 6, -39, -1, 36, -23, 76, 8, 36, -17, 33, -44, 3, 30, 17, -7, 32, 30, 39, 19, 12, -44, 53, 6, -9, -7, 16, -68, -4, 44, 6, 23, 5, 17, 98, -26, 28, -19, 34, 24, -8, 39, 1, -69, 7, 51, 24, 37, 7, 24, 127, -4, 28, 61, 23, 13, -9, 77, 8, -99, -8, 41, 2, 70, 6, 3, 127, -30, 41, 71, 19, -20, -13, 41, 28, -99, 12, 20, 17, 30, 20, -10, 127, 12, 3, 20, -1, -35, -6, 89, 57, 127, 5, -20, 14, 4, 24, 20, -44, 33, 10, -32, -23, 34, 32, -17, 8, 24, -34, -60, 52, -28, 16, 10, -128, -8, 24, -48, -26, 48, 13, -52, 6, -4, -20, -85, 16, -97, 24, 7, -47, -49, 46, -47, -1, 35, -12, 9, 13, -55, -20, -47, 32, -28, 17, 24, -43, 26, 20, 9, 26, 20, 13, -12, 5, -34, -1, 33, 32, -5, 28, -2, -1, -20, 26, 86, 66, 23, 4, 24, 10, -45, -37, 76, 39, 36, 32, 24, 94, -128, 20, 121, 78, 20, -2, 49, 20, -55, 5, 77, 34, 127, 19, 12, 127, 6, 24, 121, 41, -26, 10, 33, 34, -20, -1, 37, 16, 61, 5, -10, 127, -20, 16, 49, 34, -112, -4, 20, 49, 83, -19, -4, 19, 8, 14, 5, -37, 5, -28, -57, -32, -9, 12, -5, 12, 20, -76, -94, 13, -39, 14, 9, -93, 47, 16, -44, 16, 8, 2, -24, 20, 34, -24, -96, 34, -56, 17, 8, -44, 52, -7, -64, 7, 20, -8, 14, 1, -28, -20, -17, 6, -89, 28, 32, -32, -16, 33, 4, 24, 34, -4, -3, -4, -106, -34, 7, 28, 9, 48, 17, -32, -28, 37, 41, 9, 57, -19, 19, -14, -47, -19, 45, 9, 37, 20, 30, 60, -43, 35, 78, 46, 52, 23, 78, 12, -57, -26, 98, 45, 115, 3, 7, 111, 32, 19, 112, 26, -1, -20, 90, 37, -106, -28, 33, 34, 127, 14, 44, 127, 20, 17, 24, 41, -71, -23, -14, -23, -28, 111, -7, 30, 68, 13, 14, -24, 2, -3, -43, -16, -28, 28, -80, 17, 37, -24, -98, 14, -64, 19, 16, -47, -2, 10, -76, -10, 2, 2, -106, 17, 16, -32, -78, 35, -76, 19, 20, -44, -1, 34, -32, 6, 16, 7, -80, 10, 41, -52, -24, 14, -81, 20, 14, -70, -17, 36, -36, 8, 47, -19, -1, -20, -12, -16, -7, 10, -45, -1, 4, -68, -99, 3, -9, 20, 76, -16, -41, -35, -24, -4, 65, 8, 28, 28, 7, 2, 36, 12, 36, -4, 75, 4, -61, 2, -112, -41, 90, 20, 127, 10, 8, -45, 4, 61, 44, -45, 74, 1, -53, 6, -115, -61, 39, 16, 127, 2, 28, -41, 10, 12, 19, -6, 28, 5, -64, 8, -97, -80, -17, 10, 77, 32, 14, -7, -35, 20, -34, -19, 23, 28, -53, 6, 12, -28, -106, 14, -61, 14, 28, -56, 1, 32, -24, -9, 17, 28, -78, -5, 43, -46, -69, 37, -77, 36, 16, -39, -23, 48, -43, -1, 2, -12, -66, 7, 44, 8, -35, 30, -69, 28, 12, -56, 16, 14, -54, -5, 23, -19, 9, -12, 41, -78, 10, 24, -90, 6, -1, -74, 14, 39, -28, -6, 28, 1, -2, -16, 48, -60, 83, 19, -13, 24, 16, -28, 127, 13, 10, -8, 52, 9, 35, -26, 47, -28, 127, 20, 110, 17, 37, -41, 1, 26, 2, -83, 41, -13, -35, 8, -60, -14, 83, 17, 127, 36, 26, -54, -19, 39, -3, -44, 43, -7, 17, -3, -94, -77, -9, 12, 104, 24, 7, -33, -10, 20, -48, -16, 23, 10, -37, 32, 8, -76, -78, 35, -89, 13, -32, -19, -13, 30, -52, 1, 8, -6, -49, 36, -33, -32, -61, 33, -81, 39, 33, -14, -24, 26, -24, 8, 5, 1, -9, 9, -41, -44, -6, 28, -64, 28, 14, -19, -20, 7, -24, 13, -2, -8, 16, 1, -16, -39, 28, 28, -74, 30, 13, -24, -54, 20, -41, 7, 1, -23, 20, 5, 26, -64, 74, 26, -13, 7, 20, -35, -46, 23, -44, -19, -2, 7, -12, -3, 41, -99, 98, 9, 51, 44, 23, -41, 5, -2, -33, -55, 5, 9, -41, 14, 60, -81, 90, 37, 127, 17, 23, -77, -41, 30, -37, -52, 65, -23, 6, 41, -99, -61, 8, 24, 75, 16, 17, -37, -14, -17, -57, -43, -3, 16, 32, 43, 48, -65, -96, 10, -83, 13, -33, -65, -32, -16, -78, -3, 5, 3, 24, 41, -37, -60, -82, 3, -99, 19, 17, -24, -106, 9, -57, 20, 4, -24, 43, 34, -49, -45, -1, 32, -106, 20, 20, 28, 2, 34, -9, 61, -16, 2, 90, 60, -34, 19, -24, 45, -117, 19, 12, 14, -6, 32, -20, 41, 1, 14, 119, 46, -33, -6, 3, 13, -114, 26, 19, -34, 9, 17, -37, 1, -23, 4, 76, -16, 26, -45, 24, 20, -76, 23, 4, -83, 4, 30, -54, -51, -1, -7, 80, 28, 80, -128, 55, 5, 9, 20, 4, -93, -1, 17, -9, -48, 9, 9, 127, 28, 33, -128, 23, 24, 28, 14, -4, -37, -55, -6, -71, 1, -37, 7, -20, 19, 108, -20, -83, 23, -110, 33, 19, -128, -103, -17, -114, 9, 20, -5, 1, 34, 35, -39, -45, 33, -81, 46, 36, -99, -85, -4, -65, 20, 36, 1, -43, 48, -83, -26, -3, 28, -76, 30, 20, -64, -45, 41, 17, 41, 16, 13, -23, 60, 1, -20, -44, 26, -20, 33, 41, 2, -20, 36, 46, 68, 33, 20, -34, 49, -91, 3, -32, 19, -26, 28, 10, -33, 6, 44, 8, 39, -9, 7, -19, 39, -17, 4, -8, 12, -98, 33, 6, -60, 7, 14, -41, 41, -16, -12, -52, 24, 33, -3, 49, 13, -28, 9, 12, -71, 7, 17, -30, -34, 30, -13, -41, -4, 93, -115, 44, 28, 5, 19, 8, -12, -28, 7, -54, 33, -41, -10, -36, 45, 66, -4, -128, 20, -124, 37, 19, -70, 9, 10, -107, 23, 35, -23, -8, 20, 78, -17, -75, 19, -128, 13, 3, -53, -45, -4, -107, 12, 41, 12, -54, 9, 26, -37, 41, 17, -117, 17, 8, -47, -8, 9, -26, -7, 33, -3, -24, 55, -83, -86, 35, 20, -4, 13, 14, -8, 19, 30, 24, -7, 33, -9, 12, 43, -82, -39, 12, 45, 49, 12, 20, -12, -26, 5, 10, 10, -7, -4, 64, 28, 10, 8, -28, 24, -14, 33, 10, -8, 6, 3, -83, 53, -1, -9, 124, 7, -5, 32, 17, 32, -69, 24, 12, -24, 32, 14, -51, 65, 46, 14, 108, 14, 20, 46, 53, 10, -19, 24, 7, 28, 68, 41, -80, 64, -12, 12, -24, 36, -35, -4, -94, 28, -76, 30, -20, -9, 75, 20, -80, 39, -5, 10, -6, -5, 66, -9, -75, 20, -98, 5, 34, -9, 20, 2, -46, 24, 17, -19, -41, 41, 37, -28, 48, 32, -124, -2, 14, 6, -6, 14, 6, -4, 20, 7, 2, 20, 20, -24, 26, 48, -9, 13, 24, 1, -91, -13, 2, 3, 26, -4, -19, 33, -71, -9, 16, 28, 46, 2, -19, 43, -8, 37, 16, 10, -14, 24, 26, 35, -14, -8, -9, 24, 48, 2, 2, 3, -41, 39, -19, 16, 6, -1, 89, 5, 52, 1, 2, 37, -90, 20, 7, 7, 12, 36, -39, 41, 57, 13, 127, -36, 71, 24, 35, 47, -36, 10, -3, 43, -48, 46, -9, 56, -2, -13, 60, 19, -45, 28, -128, 19, -74, 33, -3, 44, -53, 14, -28, 69, 8, 7, 55, 14, -3, 3, -128, 24, -125, 28, -6, 3, 5, 20, -14, 45, -4, -3, 33, 33, 44, -2, 8, 52, -128, 32, 9, -1, -10, 43, 12, 16, 8, 23, 20, 26, 28, -26, 52, 37, -81, 23, 20, 37, -4, 60, 20, 24, 28, 17, 20, 55, -2, -28, 35, 24, -6, 19, 1, 60, 8, 57, 36, 47, -5, -10, 32, 30, -30, -2, -19, 9, 10, 23, 12, 76, 20, 4, 6, 61, -24, -8, 75, 26, 32, 13, 7, 28, -128, 37, 28, 19, 20, 28, -20, 53, 111, 33, 127, 5, 77, 13, 41, 24, -80, 33, -12, 33, -24, 34, -13, 66, 39, -5, 57, 28, -32, 45, -128, 30, -82, 16, -14, 28, -3, 23, 10, 60, 20, 9, 99, 9, -19, 32, -118, 24, -80, 1, -8, -6, -13, 17, 5, 48, 33, -2, 127, 53, -8, 9, -104, 30, -83, 30, 32, 6, 114, 24, 33, 51, 34, 13, 52, 10, 78, -30, 44, 43, -45, 28, 13, 19, 104, 60, 24, 35, 10, 7, 41, 16, 32, -10, 52, 44, -1, 14, 3, 45, -13, 118, 16, 44, 41, -30, 20, 4, -20, 5, -4, 24, 12, -9, 14, 56, -28, 99, 30, 57, 16, -35, 17, 17, 16, 48, -24, 23, -91, 13, 4, 24, 24, 98, 14, 80, 68, 8, -71, 5, 48, 47, 34, 20, -53, -53, -111, 44, -58, -62, -5, -32, 16, -128, -13, -113, -10, -95, -10, -74, 55, -46, -54, -26, 25, -55, -83, 79, -74, -29, 4, -61, -42, -72, -23, -40, 74, -109, -110, 23, -16, -37, -62, 57, -26, -55, -45, -128, -98, -64, -64, -54, -58, -85, -11, -66, 91, -67, -58, 19, -48, -1, 95, -18, -92, 21, -48, -99, 27, -65, -6, -4, -31, -46, -29, 19, -120, -115, 10, -31, -19, 81, -91, -94, 10, -111, -44, 69, -32, -13, 31, -34, -3, -48, 69, -35, -87, -19, -78, -80, 101, -80, -76, -77, 16, -10, -101, -87, -128, -40, 3, -64, 69, 92, -35, -3, -46, -128, -61, -18, -37, -46, -99, -4, -127, 31, -36, -17, 60, -37, -25, -108, 64, -46, -92, -46, 26, -43, -11, -13, -126, -120, -101, 78, -71, 81, 49, -128, 113, -42, -34, 6, -128, -12, -25, 18, -45, -97, -97, 3, 12, -24, -33, -128, -49, -91, -113, 87, -74, -45, -65, 46, -6, -81, -12, -41, -53, -1, -115, -80, -20, -128, -124, 36, 27, -36, -61, -88, -60, -55, -55, -27, -13, -16, -27, -99, -41, -45, -33, 8, -45, -75, 2, 39, -31, -88, -91, -9, 127, -23, -90, -98, -54, -90, -118, 26, -19, -87, -29, -86, -115, -57, -35, -49, -61, -67, -66, 11, -12, -77, -102, -115, -50, -37, -43, 39, -52, 27, -128, -126, 78, 43, -128, -58, -48, -83, -40, -104, -1, -52, -124, 55, -71, -1, -110, -124, -55, 55, -18, -104, -27, -2, 13, 60, 17, -102, -66, -70, -39, -71, -42, 107, -95, -29, -16, -128, -24, -104, -40, 60, -42, -87, 67, -100, -124, -83, 32, -128, -97, 43, 10, -19, -31, -61, -118, -60, 127, -128, 40, 99, 16, 27, -52, -44, -34, 2, 8, -128, 32, -78, -97, 8, 65, -53, 45, 2, -54, 83, -92, -69, 5, -6, 21, -74, 45, 89, -80, -128, 58, -67, -43, -128, -103, -8, -34, -64, -26, -44, 48, -92, 94, -104, -43, 80, -77, -72, 26, -31, 10, -4, 6, -91, -107, 58, -27, -67, -45, -34, -25, -43, 71, -37, -19, 1, -115, 36, 55, -32, 106, -12, -100, -109, 61, 66, -99, -25, 5, -76, 87, 13, -75, -37, -65, -67, -43, -10, -128, -128, 41, -8, -5, -33, -108, -35, -40, -98, -80, -85, 54, -106, -34, -109, 75, -55, -40, -97, -116, 41, -62, 8, -61, 127, -128, -103, 31, -13, -128, -61, -88, -107, 19, -72, -5, -11, 87, -127, 13, 85, -66, -19, 61, 17, -128, -1, -70, -10, 34, -13, -118, -32, 11, -49, 67, -54, -17, -13, -27, -2, -48, -12, -29, -115, 13, -13, -99, -9, 44, -20, 41, -70, -97, 21, -21, -60, -12, -46, -18, -20, 18, -20, -27, 40, -48, -55, -34, -81, -66, 19, -29, -43, -50, -31, -103, -16, 54, -27, -36, -13, -21, -19, -6, -97, -128, 44, -6, -95, 87, -72, -34, -100, 92, 25, -128, -31, -79, -70, -25, -65, -34, -61, 16, -31, 1, -23, -3, -13, 67, -109, 115, 39, 75, -98, -4, -76, -128, 67, -16, -70, -126, 35, -48, -65, 8, -95, -128, -55, -118, 2, -13, 46, -95, -9, 13, 85, -4, 2, -24, -31, -2, 41, 1, -20, 85, -86, -25, 46, -4, 13, 81, -71, -92, 58, 20, -32, 3, 49, -20, -12, -64, -44, 48, -116, -122, -26, 25, -27, -128, 20, -6, -48, -18, 13, -94, 5, 53, -76, 18, -41, -36, 13, 9, -24, -29, 25, -89, -21, -90, 67, -1, -9, 80, -10, 44, -95, -44, 44, 43, -24, -66, -18, -111, -76, -19, -12, 2, -100, -71, -60, 33, -53, 2, 8, 58, -128, 117, 1, -106, -100, -29, 18, -34, -18, -115, -50, -88, -66, -72, -37, -46, -105, 57, -33, -108, -74, 49, 40, 89, -20, -46, -128, -80, -24, -86, 43, -89, -94, -62, -94, 8, -128, 12, -52, -109, 65, -71, -1, 13, -128, -70, -55, -78, -27, -8, -4, 21, 1, -43, 83, -18, -57, -78, -43, -94, -102, -62, 65, -99, -27, -43, 54, -46, -101, 54, 87, -9, 58, -80, -116, -53, -33, -128, -29, 43, -25, -13, 6, -9, -64, 19, 34, -31, 36, -99, -17, -12, -50, -48, -16, -52, -3, -98, 10, -106, -11, 1, -25, -124, -88, -61, -57, -27, -104, -42, 6, -58, -13, -109, 61, -126, -23, -25, 76, -24, -61, -71, -76, -60, -86, -81, 5, 6, -128, 83, -53, -83, -128, -2, 13, -67, -60, -3, -32, 50, -88, -113, -17, -23, 126, 34, -11, -128, -117, 67, -17, -34, -16, 74, -91, 29, -41, -53, -97, -128, -106, -64, -35, -78, -20, -20, -88, -52, 4, -85, -128, 8, 4, -79, -40, -103, -24, -26, -61, 35, -31, 1, -61, -70, 118, -32, -118, 23, -43, -94, 42, -35, 2, -19, -43, -34, -105, -6, -8, -4, -25, -115, -80, 27, -20, -69, 13, -55, -102, 8, 78, 34, -89, -34, -92, -54, 31, -35, -83, -58, -107, -94, -10, -27, -27, -91, 33, -60, 4, 9, -92, -92, 13, 17, -91, 9, -81, -61, -65, -39, -89, -60, 17, -109, -104, -94, 91, -52, -128, 111, -128, 24, -18, -10, -24, -1, -107, 71, 6, -120, -27, 4, 50, -102, -66, -48, -70, -89, -39, -66, -19, -58, -127, -19, -5, -71, -58, 27, 43, 23, 3, -92, -111, -104, -103, -108, -116, -127, -85, -81, 6, -53, -92, 5, -117, -45, -87, -37, -32, -41, -33, -21, -70, -65, -106, -16, 18, 27, -18, -18, -128, -100, -18, 16, -54, -46, -32, -91, 25, -31, -90, -102, -19, -58, -17, 9, 29, -1, -45, -19, -128, 67, -98, -128, 20, -71, -123, -87, 74, -66, -60, -87, -37, 3, -21, -67, -23, -32, -108, -75, 5, -62, -126, -128, -49, -11, -109, 32, 48, -88, 16, -37, -79, -8, -10, -36, 70, 35, -52, -99, 5, -88, -11, 33, 65, -128, -102, -10, -48, 1, -29, -81, 1, -13, -71, -44, -5, -79, -46, 6, -17, -6, -76, 8, -128, 127, -33, -27, 65, -1, 6, 92, 3, -124, -35, -41, -86, 9, -5, -76, -109, 17, -31, -128, -13, -67, -61, -118, -87, 21, -3, -5, 102, -88, 55, -45, -128, -13, -105, -72, -74, -128, -95, -27, 42, -10, -128, 6, -66, -37, -81, -81, -76, -25, -66, 6, 61, -81, -74, -25, -39, 3, -111, 46, -16, -43, 9, -64, -71, -36, -34, -58, 3, -97, -27, -62, -57, -32, -33, 54, -65, -97, -10, -85, -103, -42, 8, -71, 92, -78, -71, -50, 25, 6, -8, -55, -19, -13, 10, 12, -92, 76, -35, -117, 36, 65, -62, -55, 37, 81, -72, 5, 61, 16, -111, 2, -106, -78, -58, 5, 1, -35, -23, -75, 25, -48, -85, -27, 11, -61, -85, -99, -128, -61, -45, -89, -1, -83, -128, -36, -16, -64, -79, -19, -24, 45, -2, -27, -57, -91, 17, -19, -67, -50, -65, -60, -92, 29, -44, -124, -61, -32, 19, -124, -77, 34, -128, -77, -55, -20, -107, -98, 16, 71, -11, 18, -33, -111, -44, -64, -11, 6, -98, -6, -72, -24, -105, -46, 13, 29, -110, 44, 9, -105, -10, -70, -70, 27, -110, -108, 54, -81, -45, 18, 25, -44, -66, 8, 58, -91, 1, -64, -69, -69, -43, -48, 27, -117, -86, 10, 60, 111, -37, 35, 89, -79, -64, -55, -124, -26, -53, -91, -13, -21, -128, -85, 8, -49, -64, 10, 16, -8, -33, -2, -86, 77, -57, 5, -60, 86, -35, -29, -6, -127, -107, -19, -69, -53, -61, -17, -75, -74, -66, -128, 37, 35, -105, -72, 2, -27, -87, -46, 37, 33, -128, -10, 9, -55, -106, -100, -31, -89, -45, -58, -43, -58, -52, -33, -74, -43, -94, -57, -92, -6, -41, -69, -60, -6, -61, -39, -45, 4, -8, 9, -55, 19, -75, -18, -99, -102, -24, -128, 70, -111, -116, -1, -120, -12, -128, 49, 1, -16, -85, -128, -32, 37, -71, -45, 64, -34, -66, -9, 46, -6, -45, -44, -13, -60, -60, -86, -92, -88, -52, -85, -42, 52, -65, -128, 17, -25, -70, -13, 6, -111, -90, -24, -92, -9, -103, 25, -81, -12, -6, -9, -128, -128, -124, -45, -24, -52, -128, -124, -75, -27, -37, -57, 2, 127, -43, -100, -36, -29, -23, 12, 31, -110, -128, -66, -72, -1, -40, -39, -6, -72, -10, -62, -48, -48, -70, -128, -32, 54, -102, -50, -37, -36, -98, -42, -23, -20, -110, -64, -117, 26, 6, -23, -23, -24, -4, -113, -128, 13, -88, 52, 5, -127, -120, -55, -71, 71, 4, 83, -27, -128, -1, -27, -77, 27, -53, -9, -34, -17, -45, -75, 34, -1, -116, -60, -72, -21, -40, -64, -86, 64, -26, 23, 26, -46, -27, -29, 23, 48, -107, 10, 32, -122, -60, -62, -128, -57, -101, 27, -9, -31, -65, -85, -76, 25, 1, -26, 1, -34, 76, -61, -23, -18, -113, 37, -10, -120, 95, -52, -25, -52, -106, -23, 32, 13, 88, -27, -55, -49, -55, 11, -21, -107, -75, -26, 19, -54, -48, 37, 127, -92, -99, -24, -8, -6, -31, -111, 1, -13, -128, -26, -65, -65, -71, -66, 21, 8, 78, -73, 18, 27, 1, -62, 27, 55, 21, -60, 54, 15, 24, 99, -1, 21, 63, 15, 14, 31, 6, -1, 8, 76, 31, -47, 54, 67, 23, 76, 33, 36, 67, 12, 27, -23, 27, 12, 1, 56, 43, 51, 15, 36, 6, 50, 33, 24, 73, 99, 27, -38, 2, -4, -27, 31, 33, 85, 46, -2, 21, 19, 27, 3, 102, 126, 38, -3, 31, -49, -24, 28, 31, 57, 2, -8, 31, 15, 18, 12, 18, 126, 21, 1, -36, 12, -18, 23, 23, 60, -2, -2, 21, -5, 5, -4, -1, 85, 21, -16, -21, 62, -2, 3, 5, 101, 8, 46, 14, 34, 23, -27, -34, 3, 12, 6, -16, 106, 8, 47, 21, -19, -5, 72, 42, 63, 19, -23, 70, 12, 33, 36, 2, 53, 1, 37, 5, -38, 63, 28, -2, 49, 15, 21, 69, 73, 23, 31, 15, 76, 15, 33, -3, -72, 36, 54, 36, 67, 21, 1, 76, 126, 33, 15, 43, 28, 2, 28, -8, 23, -12, -38, 43, 15, 19, 37, 63, 110, 2, 23, 54, -12, 3, 31, 12, 83, -19, -62, 8, 21, 14, 4, 50, 111, 27, 21, 47, -47, 5, 12, 2, 69, 8, -49, 21, -24, 28, 1, -34, 84, 18, -12, 28, -33, 1, -37, 12, 88, -5, -47, 42, -85, 31, 27, -49, -3, 27, -6, 1, 85, -3, -23, 14, 86, 14, 34, 23, -53, 16, 18, -42, 1, 23, -23, 5, 126, -6, 4, 16, 23, 8, 84, 23, 12, 36, 5, 69, 126, 45, 37, 36, 51, 15, 69, 2, -15, 38, -3, 3, 49, -4, 28, 69, 122, 78, 45, 69, 31, -3, 23, 28, -37, 50, -4, 5, 49, -6, -3, 45, -49, 84, 49, 73, 33, -2, 57, 15, -31, 31, -37, 1, 1, 2, 8, 77, 6, 37, 34, 73, -1, -1, 78, 12, 8, 28, -43, 4, 97, 18, 2, 121, 5, 70, 15, 34, -31, 6, 38, 62, 43, 38, -62, 34, 37, 1, 12, -2, 8, 55, -4, 4, -34, 15, 5, 45, 103, 18, -38, 36, -36, -2, 16, -60, 23, 16, -12, 4, 33, 12, 47, 43, 126, 63, 37, 27, -51, 16, 38, -49, 4, 33, -19, 3, 108, -2, 87, 14, 110, 70, 67, 31, -6, 15, -2, 45, 43, 1, 31, -21, 6, 1, 14, -53, 31, -21, 4, 24, 70, -2, 14, 36, 87, 5, 3, -1, 63, -4, -47, -42, 1, 43, -28, 5, 27, 15, 16, 28, 2, 18, 38, 31, 63, -16, 21, -18, -27, 46, -43, 27, 37, -1, 15, 60, 38, 33, 2, 47, 12, -6, -2, -23, -128, 49, -80, 16, 69, 6, 16, 121, 28, 8, -4, 43, -1, -15, -58, 37, -33, 45, -69, 27, -3, 18, 12, 67, 2, 8, -1, 58, -28, 1, -80, 70, 51, 56, -80, 36, -56, 12, 16, -33, -3, 24, -15, 101, -14, -3, -27, 2, 125, 106, -4, 14, -67, 16, 21, -12, 16, 23, -1, 80, 51, 8, 69, 5, 94, 36, 76, 37, -51, 4, 8, -57, -36, 1, -8, -62, 16, 31, -5, -63, 63, -2, 27, 19, 73, 8, -1, -18, -19, 38, 1, -50, 19, 12, 4, -54, 1, -2, 37, 34, 67, 5, 8, -6, 37, 58, 43, -31, 38, 15, 1, -19, -43, 50, -5, 31, 38, 33, 6, 37, 47, 53, 6, 8, 45, 4, -23, -28, -58, 49, -31, 14, 12, 16, 15, 103, 3, -6, 1, -8, 36, 5, -47, -1, -87, 56, -49, 6, -24, -4, -1, -57, -128, 12, -8, 24, -3, -1, -57, 84, -76, 46, -107, 34, -76, -8, 19, -87, -2, -1, 46, 84, 12, -2, -42, 18, 78, 69, -50, 27, -99, 21, 16, 4, -1, -16, 23, 122, 47, 8, -15, -3, -53, 23, 58, 27, -49, 18, -14, -88, 60, -84, -19, -76, -19, 34, 23, -36, 42, -43, 77, 28, 46, 37, 23, -72, 111, -21, -1, -45, 27, 6, 19, -38, 47, -33, 77, 16, 102, 14, 24, -37, 117, -34, 12, -53, 34, -1, 42, -16, -33, 1, -16, 24, 72, 15, -1, -28, 78, 21, 42, -46, 8, -1, 27, -1, -53, 42, -8, 5, 72, 18, 16, 27, 80, 47, -15, 14, 50, -1, -1, 24, -97, 86, -55, -4, -54, 18, 4, -128, -51, 42, -43, 3, 38, -8, -15, 38, -84, 67, -76, 21, -47, 18, 24, -101, 6, 24, 19, 47, 50, -1, 18, -2, -36, 16, -54, 12, -54, 5, 8, -43, 3, 46, 43, 27, 70, 3, 1, -46, -88, -89, 45, 21, -27, 33, 8, -69, 5, -80, -42, -50, -31, -1, 27, 8, 56, 37, 1, 33, 37, 33, 37, -37, -45, -6, -31, -62, 19, 1, 67, 4, 31, -14, 49, 21, 19, 36, 14, -43, -84, -14, -15, -38, 34, -14, 42, 38, 105, -6, 54, 15, 14, 24, 1, -19, -42, 21, -2, -38, 15, 14, 4, 47, -4, 43, 4, 8, 78, 28, 28, 33, -54, 24, -6, -19, 28, -1, -54, 36, -62, 58, 16, 18, 1, 37, 8, -70, 50, 53, -6, -6, 2, -5, -128, 80, -86, 102, -37, 12, -72, 33, 34, -107, -14, 15, 31, 86, 12, -2, -122, 19, -43, 56, -33, 27, -31, 27, 36, -34, 21, 28, 2, 18, 49, 1, -88, 14, -24, -76, 14, 31, -42, 3, -14, 8, -36, -36, -34, -4, -80, 2, -21, 16, 107, 16, -55, 28, -37, 5, 15, -31, -43, -4, -16, -18, 21, 2, -47, 3, 42, 3, -31, 38, -42, 33, 23, -16, -43, -18, -36, -15, -12, -2, -34, 69, 62, -1, 62, 27, 4, 15, 3, 6, -27, 12, 15, -43, 16, -1, -50, 57, 63, 24, 34, 43, 50, 2, 5, 63, -77, -1, 34, -15, 2, 1, -80, 36, -42, 60, 8, 27, 28, 24, 18, 126, -28, 34, 18, -4, 18, -1, -128, 62, -60, 73, 6, 34, -53, 2, 8, 53, -6, 23, 34, 58, -78, 1, -51, 56, -33, 80, -51, 6, -55, 31, 21, 62, 4, 37, 36, 31, -58, 18, -73, 57, 72, -49, 8, 28, -72, 4, 6, 24, -1, 5, -1, 62, -55, 15, -2, 19, 27, 34, -47, 28, -31, 19, 15, -33, -16, 1, 1, 47, 21, 4, -12, 27, 55, 54, -18, 42, -21, 28, 31, 5, -15, 47, -3, 38, -27, 4, -14, 73, 42, 56, 51, 28, -23, 1, 1, 16, 21, 46, 47, 5, 1, 3, -50, 84, 45, 4, 55, 51, 4, 24, 12, -15, -14, 3, 94, 3, 28, -2, -80, 36, -8, 63, 36, 16, 36, 15, 8, 83, -12, 47, 102, 43, 31, 2, -128, 18, -2, 110, 28, 34, 2, 23, 6, 124, 8, 19, 105, 99, -55, 1, -128, 63, -108, 126, -46, 42, -76, 16, 19, 36, -2, 34, 103, 112, -126, 2, -128, 55, 36, -4, -16, 12, -45, 15, -3, 38, -36, 12, 16, 56, -4, 1, 46, 46, -38, 16, -15, 16, -5, 21, 6, 16, -57, 15, -4, 54, 47, -1, 62, 27, 54, 4, -49, 12, -38, 3, 23, 18, -23, 1, 6, 49, 6, -8, 12, 45, -1, 4, 5, 31, -54, 27, 31, 5, -8, -56, 34, 67, 1, 1, -5, 34, 34, 15, 42, 33, -14, 14, 8, -43, 21, -73, 94, 19, 70, -4, -28, 23, 38, 4, 56, 28, 5, 33, 14, -2, 21, -50, 121, -12, 80, 15, -58, 12, 31, -15, 45, 12, 8, 28, 4, 87, 19, 28, 111, 19, 21, -1, -128, 87, -89, 63, -3, 5, -24, 14, 24, 126, 18, 28, 94, 73, -128, 8, -128, -3, -55, 105, -53, 4, -12, -1, 2, 53, 12, 24, 19, 55, 38, -3, 46, 12, -18, 28, -56, 3, 2, 19, -2, 28, 46, 24, 3, 60, 43, -3, 54, 18, -23, 31, -67, 18, 1, 14, 15, 3, 6, 8, 28, 69, 19, -6, 18, 19, 6, -4, -14, 28, -27, 18, 15, 2, -69, -19, 6, 62, 23, 19, 12, -1, 27, -24, 67, 23, -51, 23, 24, -73, -50, -76, 33, 54, 16, 8, -33, 12, 86, -43, 80, 21, -12, 19, 12, -56, -55, -84, 47, -23, 8, -4, -128, -1, 114, -106, 126, 15, 121, -8, 5, -54, 3, -108, 33, -57, 27, 14, -128, 42, -3, -99, 58, 31, 53, -18, 14, 21, 1, -8, 36, -80, -128, -34, -128, -31, -73, -53, -23, 15, 80, 28, 1, 50, 34, 49, 19, 42, 36, -15, 50, 36, -4, 21, -72, 5, 38, 4, 12, 36, 19, 51, 3, 50, 27, 16, 34, 53, -8, 63, -70, 5, -3, 23, -14, 3, 6, 38, 12, 57, 24, -16, 21, 24, -1, 43, -51, 14, -1, 31, -16, 2, 3, 76, 34, 46, 12, -4, 18, 18, 43, 31, 34, 37, 6, 15, 15, -100, -83, 18, -19, 38, -49, -2, -15, 38, 124, -49, 83, 16, -19, 12, 16, -128, -111, -126, 27, -24, -58, -8, -34, -34, 126, -78, 126, 24, 99, -3, 34, -128, -84, -5, -19, -100, -89, -8, -43, -6, 33, -107, 117, 18, 126, -23, 6, 27, 24, -117, -15, -128, -128, -38, -69, 28, -56, -128, -23, 18, 126, -25, -72, 73, 64, -20, -128, 97, -38, -20, 45, 83, -104, 49, 70, 60, 72, -16, -47, 73, 80, -50, 3, 72, -21, -45, 83, 54, -128, 27, 40, 20, 106, -17, -40, 80, 64, -25, -16, -24, -18, 3, 60, -5, 49, -26, -25, -24, 50, -43, -2, 80, 46, -24, 14, 75, -72, 5, 2, -46, 99, -26, -45, -21, 54, -14, -49, -3, -3, -26, -1, -100, -72, 46, -16, -45, 88, 3, -49, 3, -2, 1, -49, 49, 17, -18, 5, 5, -49, -2, 26, -40, 18, -25, -38, -18, -38, -38, -25, -60, -73, -25, -27, 1, -27, -20, -25, -43, -73, -16, -64, -38, -14, -38, -24, -70, 21, -21, -16, 26, -75, -27, -18, -17, -16, 40, -96, -28, -45, -1, -21, 64, -28, -75, -115, 126, 16, -49, 100, 100, -128, 3, 24, -64, 70, -27, -26, 54, 73, -45, -70, 100, -74, 1, 80, 28, -123, 84, 96, 16, 104, -43, -46, 25, 126, -49, -38, 74, -26, -46, 73, -90, -21, 64, 16, -64, 75, -70, -40, 20, 3, -28, 43, 24, -74, 25, 50, -64, 106, 28, -84, -46, -18, -38, -40, -24, 24, -38, -27, -100, -73, 24, -17, -28, -1, -14, -26, -16, -45, -20, -46, -99, 43, -40, -72, -64, -18, 16, -113, -64, -1, 54, -28, 46, -90, 28, -18, -72, -14, -43, -24, 3, -1, 24, -81, 16, -47, 20, -43, -27, -1, -60, -14, -3, 64, -27, 54, 80, -74, 17, -100, -5, -81, -21, -45, 18, -2, -47, 47, 49, 96, -3, 73, 126, 16, -2, 93, -128, -122, 21, -88, -18, 25, -43, -21, 80, 43, -21, 80, 16, -1, -70, 126, -43, -123, 45, -5, 60, -45, -20, -40, 25, 106, -3, 99, 21, -38, -1, 126, -27, -50, 74, 16, -38, 25, -28, -21, 18, -50, -26, -18, -46, -45, 17, 83, -90, -17, -17, -93, -21, -75, -28, -72, -121, -38, -99, -17, -50, -83, 5, 45, -81, 26, 16, -27, -45, -38, -64, 2, -88, -26, -5, 17, -70, -40, -28, 28, -93, -17, -18, -14, -25, -27, -40, -27, -43, -46, -38, -26, -81, -38, -28, 14, -119, 5, -96, -25, -74, -90, 18, 60, -17, -40, -16, -1, -72, -80, 21, 2, -16, -88, 27, -49, -14, -1, 27, 5, -16, 126, 27, 20, 2, 84, 70, -1, -128, -60, -25, -21, -28, 25, -20, -45, -1, 24, 70, 5, -2, 25, 21, -38, -24, -128, 16, 38, -45, -26, -45, -25, -46, 25, 14, 54, -1, -20, 45, -14, -16, -128, 45, -25, -49, -18, -18, -46, -20, -40, -14, 5, -1, -1, 21, -45, -106, -40, 38, -83, -40, -3, 16, -38, -75, -128, -45, 3, -40, -54, 20, -50, -88, -113, 38, -113, -26, -54, -21, -27, -123, -40, -103, -21, 26, -46, -17, -38, -90, -2, 14, -70, 1, -60, -3, -28, -46, 45, -27, 5, -3, -27, -5, -128, -83, 49, -103, -40, -18, -50, -1, 16, -25, 1, -20, -1, -45, -93, 2, -72, -21, -40, -99, -46, -20, 17, 27, 70, -83, 126, 126, -18, -43, 116, 28, 20, -83, -60, -50, 14, -24, 50, -72, 60, -90, 80, 3, 2, -97, 104, 26, -20, -27, -74, -45, -2, -20, 93, 38, -40, -27, 28, -20, 17, -26, 90, -1, -1, -40, -83, -5, -38, -47, 100, -1, -20, -60, 18, 88, -122, -18, 21, 20, -5, -46, -64, 2, 25, -20, 45, 40, -20, -73, -113, 115, -28, 3, 1, -5, 46, -116, -75, 1, -93, -43, 18, 17, -40, 24, -96, 18, 16, 60, -104, 21, 72, 1, -40, 25, -28, -2, 88, 18, -27, 81, 40, -17, -16, 75, -100, 27, -2, 1, -26, -5, -16, -54, -24, -5, -26, 14, 38, -1, -20, -43, -103, 40, -1, -104, 27, -128, -83, -25, -24, 1, 28, -74, -27, -54, -43, -70, 1, 40, -20, -123, 38, -75, 50, -2, -47, 46, 47, -49, 49, 5, 1, -80, 70, -3, 49, -128, -119, -40, 46, -54, 5, 72, 70, 2, 50, -43, -20, -119, 99, 20, 45, -113, -90, -25, 16, -47, 74, 3, -26, 16, -1, -2, -84, -46, 126, 21, 18, -1, -96, 1, -21, -28, 73, 20, -26, 93, -45, -18, -43, 64, 47, -16, 74, 20, -43, -26, -49, -18, 40, -2, -21, 126, -14, 3, 123, 50, -60, 25, 40, 47, -64, -17, 73, -20, 113, 5, -20, 80, 38, -60, 126, 99, -128, 18, 14, 16, -3, -54, -38, -2, 21, -20, -16, 17, 20, -26, 3, 73, -121, -17, -5, -21, 45, -84, -90, -24, -20, 5, -3, -93, 16, -81, -20, -49, 24, -3, -28, -64, 47, 3, -16, -1, -28, 21, 38, -75, 54, -54, -60, -81, 28, 72, -80, -128, -2, -64, 3, -46, -40, -3, 25, 43, -20, -70, -80, -88, 74, -2, -84, -100, -128, -25, -75, -3, -24, -26, 49, 3, 2, 72, -1, -25, 93, 5, 2, -54, -72, -2, -47, -21, -88, -18, -17, 45, -43, -25, 25, 2, 93, 21, 74, 3, -38, -45, -21, -25, -28, 3, -26, 104, -47, -72, 80, 21, 25, 3, 38, 16, -43, -121, 96, -21, 126, -40, -47, 99, 1, -5, 25, 60, 2, 28, -47, 2, -100, -113, -64, -1, 97, -5, -20, -96, 24, -5, 25, 80, -113, -17, 126, -93, -1, -128, -72, -16, -2, 1, -16, -84, -26, -97, -96, -99, -45, 1, 5, -28, 40, -5, 14, 18, 1, 38, 17, -80, -88, -73, -47, -88, 49, 2, -28, -97, 18, -96, -2, -14, -43, 2, 49, -64, -46, -46, -43, -75, 17, -17, -73, -74, -128, -72, -21, -2, -40, -3, 74, -14, -14, 5, 50, -40, 17, -17, -24, -128, -50, -96, -43, -14, 18, 14, 50, -49, -74, 16, 46, -16, 16, -1, -128, -60, 90, -72, 46, -24, 38, -16, 3, -43, -17, -28, 18, -20, 84, 14, -75, -128, -45, -26, 54, -3, 113, -1, -26, -128, -27, -18, 1, -88, 54, -24, 46, -128, -113, -5, -24, -16, 103, -5, -49, -128, -17, -14, 5, -50, -24, -1, -5, -47, -123, -104, -45, -25, 21, -27, 3, -17, -47, -18, -25, -16, -84, 24, 1, -43, 47, -81, 16, 21, -90, -26, 3, -2, -28, 14, -40, 3, -16, 25, 40, -47, 60, -27, 2, -46, -27, -17, 28, -21, -90, -122, -27, 20, 54, -17, 38, -25, -1, -49, 49, -2, -1, 21, 28, -26, -40, -119, -84, -74, 27, -1, 2, 47, -64, -49, 26, -38, 3, 14, 14, -40, -46, -128, -17, -73, 16, -17, 20, -25, -106, -38, 106, -38, 72, -3, -2, -75, -50, -90, -54, -84, 2, 2, 46, -128, 104, -38, 73, -45, 40, -16, -21, -116, -45, -80, -106, -119, 26, -21, 126, 60, -43, -96, 1, -21, 97, -21, -47, -75, -17, 38, -72, -64, 80, 26, 97, -24, -128, 45, -50, -64, 47, -20, 3, 1, -73, 38, -80, 50, 24, -2, 26, 54, 47, 28, -113, 27, -46, 5, -26, 18, -49, 104, -24, 84, -80, 16, 16, -106, 43, -1, -93, 49, -80, 28, 38, 24, 17, -121, -75, 40, -64, 1, -18, -83, 40, -28, 1, 40, -64, 14, 26, 17, -14, -74, 2, 40, -2, -1, -25, -73, 25, 25, 46, 24, -40, 2, -1, 17, 17, -75, -70, 60, -24, -3, 2, 38, 16, -1, 27, 49, 21, -5, 38, -1, -70, -90, -64, -14, -1, -3, 50, 5, -17, -28, 70, -40, 43, -1, 1, 28, -47, 1, -93, -99, 74, 24, 126, -25, 16, -25, -1, -18, 64, -3, -54, -5, -18, -40, -90, -99, 126, -25, 126, 16, 3, -28, -73, -49, 2, -18, 1, 21, 16, 83, -2, 74, -49, -18, 27, 90, 21, 27, 24, 5, -60, -21, -40, 16, -43, 126, -40, 50, -3, -5, 47, -40, 47, -24, -14, 74, -17, 25, -27, 24, -20, 100, -14, 46, 2, 14, -43, 40, 26, -25, 18, 45, -14, 5, -2, -45, -5, 106, 1, 26, -20, 20, -28, -70, 27, -27, -1, 50, -28, 24, 21, 43, -3, 100, -45, -47, -46, 16, -50, 16, 28, -26, 38, 5, 1, -1, 38, 16, -70, -1, -2, -43, -88, -16, 20, -20, -17, 40, 27, -50, 40, -25, 54, 64, -5, -90, -27, -60, -45, -18, 126, -14, 54, 14, 28, -54, -97, 5, -18, 21, -45, -46, 3, -90, 126, 18, 126, 5, 40, -21, -17, -17, -64, -2, 5, 21, 38, 28, 25, 50, 24, -18, 27, 99, -38, 21, -16, 28, -84, -20, 17, 26, 97, 38, -16, 24, 1, 20, 3, -73, -38, 38, -24, 24, -49, -14, -18, -40, 88, 40, -14, 20, 5, 17, -2, -1, -90, -27, -26, 3, -26, 5, -2, 5, 103, 46, -20, 18, -1, 28, 5, -75, 2, -2, 1, 50, -5, -14, 21, 21, 84, 104, -20, 38, 16, 21, -14, 21, 25, 1, 24, 20, -14, 1, 64, 75, -24, 47, -25, -50, 38, 14, 3, 1, -72, 25, -73, -45, 2, -2, 5, 47, 43, 119, -16, -28, 14, 16, -2, 96, 14, 74, -21, -25, -122, -25, 24, -27, 73, 126, 17, 26, 100, -1, -128, -18, 80, -46, 40, -38, -122, -27, -90, 23, 49, 49, -47, -78, -20, -66, 23, -81, -128, 8, -45, 10, -2, -66, -109, -83, -16, 92, -1, -77, -87, -80, -23, -17, -95, -37, -8, -124, 60, -38, -119, 21, -12, 34, 38, -12, -81, -55, -55, -121, -20, -33, -33, -54, -19, -58, -128, 8, -90, 7, -4, -68, -83, -19, -25, -128, 1, -10, -128, -11, -9, -83, -55, 4, 21, -4, 68, -60, -90, -100, -24, -60, -119, -6, -128, -119, 9, 18, -97, 48, -46, -68, 30, 38, -25, -87, 25, -47, -64, -28, -78, 50, 8, -2, 1, -28, 24, -80, -61, 53, -71, 2, -83, -86, 41, -38, -82, -38, -7, 44, 81, -59, -11, -65, -49, -6, -73, 27, 37, -65, 18, -30, -49, 12, 83, -76, -70, 25, 10, -92, -1, 10, -87, 11, -86, 30, -82, -120, -33, -94, -62, -10, -97, -4, 93, -89, -44, 45, -128, -93, -18, -71, -117, 28, 9, 17, 30, -74, -43, 59, 36, -84, -65, -49, 9, -25, -1, -55, -51, 38, -34, -98, 10, -87, -128, -24, -23, -86, -78, 34, -64, -45, 20, -34, -58, 51, -36, -10, 36, 21, -77, 9, 81, -46, -35, -14, -82, -64, 28, -102, -33, 59, -51, -28, 46, -30, 18, 6, -53, -85, 2, -47, -128, -49, -46, -66, -33, -50, -124, 7, 11, 71, -81, 23, -16, -115, -45, -20, -3, 1, 3, -5, -33, -47, -87, -71, -51, 2, -92, -4, -9, -54, 19, 74, -9, -41, -53, -35, 55, -24, -128, -5, -15, -85, 15, 23, 76, -73, -11, 49, 6, -94, -81, -83, -89, -14, -38, -110, -14, -109, -84, -16, -25, 3, 1, -14, -49, -14, 59, -79, -18, 21, 20, 6, -29, 49, -105, 15, 32, -128, -36, 1, -103, 58, 33, -73, -95, -10, 11, -128, 8, -17, -119, 16, -32, -77, 70, 3, 4, -58, 62, -85, -18, 58, 77, -46, -79, -32, -48, -3, -32, -25, 25, 18, -91, -23, -6, -73, -74, -54, 6, -128, -29, -35, -50, -1, -10, 7, 48, -49, -97, -48, 29, -8, 53, 38, -128, 3, 11, 4, -103, -5, 70, 14, 5, -17, -60, 2, 15, -51, 36, -37, -93, -14, -38, 90, -81, -21, 8, -70, -20, -16, -58, 5, 59, -111, 35, 4, -80, -53, 62, 74, 58, 1, 70, -12, 32, -25, -51, -101, -113, -64, -30, -10, -1, 5, 32, 23, 30, 37, 19, 1, -25, 45, -51, -102, -15, 91, -41, 14, -32, -37, -18, -15, -7, 32, -37, -89, 65, -24, -79, -50, -57, -30, -89, -27, 8, -46, -35, -79, -108, 15, 58, -34, -68, -4, -49, 51, -60, -58, -64, -21, 42, -97, 25, -36, -29, 71, 73, -102, -37, -127, -78, 8, 7, -92, 60, 93, 3, -101, 6, -27, -60, -16, -91, -127, 59, -50, -3, 82, -60, -101, 5, 53, -106, -79, 28, 44, -57, -42, -128, -66, -37, -25, -91, 50, -2, -37, 30, 6, -2, -126, -32, 87, -87, -108, -33, -59, -17, -126, -62, 3, -70, -66, -55, -44, -43, -93, -41, -8, -29, -45, -21, -29, 37, -61, -128, -128, -77, 2, -93, -35, 38, -9, 4, -68, -114, 30, -113, -70, -3, 38, -59, -86, -54, -93, -80, 66, 43, -70, 18, 15, -58, -65, 14, -48, -25, -43, -105, -38, -49, -101, -128, 8, 10, -102, 16, -76, -44, 57, -10, -48, 15, -116, -116, 7, 49, -44, -101, -77, 29, -68, -14, -29, -128, -17, 7, -57, 5, -17, 1, 1, 27, -85, -97, 9, 21, -17, 21, 11, -76, -19, -11, -20, 54, -84, -122, -15, -59, -49, 30, -34, -1, -42, 18, -6, -47, -17, -12, -90, 55, -37, -32, -42, -74, -41, -29, 10, -73, -61, 35, 21, -11, -25, -109, -128, 81, -68, -25, -81, 2, -32, 2, -25, -87, 21, -44, 14, -112, -17, -33, -120, 89, -85, 2, 4, -30, -3, -119, 74, 14, -76, -2, -17, -25, -17, -18, -83, 12, -1, -89, -43, 37, 51, -109, 32, 50, -89, -59, 11, -54, -17, -30, -111, 29, 74, -106, 7, 7, -128, -59, -37, -25, -68, -25, -53, -60, 37, -57, -65, 7, -35, -5, -1, -5, -117, -81, 23, 43, -128, 7, -25, -109, 15, -66, -15, 3, 35, -128, 25, -32, -93, -81, -57, -2, -7, -21, 24, -65, 73, -53, -25, -20, -128, -97, -93, -86, -128, -82, -47, -41, -80, -32, -1, -128, 16, -62, -25, -17, -115, -61, -30, 11, -128, -28, -15, -58, -70, 35, 30, -91, -68, -106, -115, -37, -81, -62, -29, 24, -24, 15, 65, -121, -58, 7, -1, 2, 17, -3, -62, 41, 20, -128, -124, -44, -62, -73, -28, -7, -11, 50, 65, -97, -95, -70, -65, -42, 15, -103, -27, 44, -28, -76, -19, 19, -128, -17, 25, -32, -59, -9, -4, 8, -25, -51, -1, 25, -19, -21, 71, -4, -91, -7, -41, -8, 2, -107, -95, -25, -12, -48, -6, -59, -112, -30, -17, 18, -48, -6, -21, -38, 10, 54, -128, -19, -126, -49, -70, -53, -62, -79, 9, 8, -98, -10, -60, -60, -16, -61, -77, -42, -128, -89, 50, 25, -108, 6, -6, -114, -111, 27, 11, -82, 20, -74, -102, -11, -15, -6, -29, 1, -97, -83, 45, -98, -109, -14, 4, -128, -61, -115, -25, 82, -12, -128, -25, 7, 30, 51, 25, -107, -117, 77, 8, 43, -15, -7, -128, -54, -97, -35, -128, 3, -43, -128, 59, -29, -55, 49, 64, 38, 1, -29, -14, 42, -54, -73, -2, -17, -15, 15, -25, -34, 2, -53, -12, -80, -5, 59, -128, 84, -51, -21, 25, 4, -23, -29, 32, -4, -29, -80, -36, -83, -23, -94, -6, 66, -55, -78, 20, 1, -94, -3, -5, -34, -128, 12, 25, -64, -38, 18, -15, -41, -42, -102, -14, 14, -94, -51, -20, -65, -68, 1, 2, -23, -48, -25, -51, -5, -87, -66, 59, -19, -10, 21, 81, -8, -8, 23, -36, -8, -82, -18, -70, 30, -103, -45, -84, 28, -25, 30, -50, -103, -128, -94, 61, -46, -86, -100, -120, 25, -70, -112, -2, 37, 60, -32, -34, -85, 8, 35, 1, -23, -12, 2, 32, -85, -91, -92, -66, -1, -77, -23, -38, -12, -77, 68, -38, -50, -6, -37, -81, -32, -64, -77, -58, -70, -76, -33, 58, 30, -70, -12, 68, -84, 71, -1, -29, 25, -121, -7, -49, 42, -10, -64, 55, 45, -128, 36, -51, 6, -4, -1, -108, -27, -10, -128, -6, 15, -25, -108, 58, 1, -128, -2, 57, -11, -49, -20, -49, 3, -111, -27, 6, -3, -117, -109, -28, 43, -73, -37, -35, -103, 35, -128, -128, -9, -45, -54, -46, -3, -87, -84, -93, -85, -81, 17, -12, -73, -65, -38, -89, 7, -78, -97, -4, 23, 28, -4, 37, -11, -61, 91, -24, -35, -61, -110, -113, -44, -25, -95, 47, -4, 82, -3, -45, -60, 6, -5, -49, -29, -24, -4, -128, 5, -98, -24, -16, -25, -79, -60, -24, -14, -103, -8, -93, -6, -10, -102, 16, -47, -68, 12, -18, 43, 81, -109, 1, -21, -35, -15, 77, -60, 15, -27, -86, -16, -112, -86, 25, 34, -46, -62, -54, 64, -103, 4, 12, -27, -3, -76, -38, -17, -90, -42, 15, -79, -73, -46, 50, -33, -57, 12, -25, -93, 28, -15, -97, 43, -85, -103, 24, 1, 6, -76, 2, 46, -97, 50, -23, -122, -11, -1, -89, -27, -50, -91, 27, -92, -110, -23, -9, -86, -128, 44, -23, -51, 25, -29, -107, 60, -112, -103, -51, 18, -79, -47, -11, -128, -29, 19, -53, -128, 3, -128, -71, 84, -105, -25, 71, 47, -120, -32, 11, -82, -44, -25, -7, 3, -2, -15, -85, -126, -11, -71, 17, -85, -128, -16, -103, 77, -84, 15, -55, 16, 17, -1, -102, -10, -9, -70, 18, -84, -89, -89, 59, -2, -107, -41, -16, 6, 50, -81, -98, -15, -11, -73, 8, 25, -17, -106, 53, 6, -70, 20, -30, -60, -7, -6, -16, 8, 7, 3, -42, 27, -65, -54, -21, -20, -114, -27, -17, -74, -3, -94, -17, -33, -128, 27, -6, 1, -110, -68, -20, -2, -128, 12, -32, 6, -84, -6, -124, 15, -109, -24, -10, 33, -115, -77, -36, -62, -58, -4, -12, -71, -103, -47, -76, -44, -128, 10, -58, 37, -48, -51, -5, -46, -47, 60, 35, -92, -48, -117, -92, 3, -128, -128, -10, -113, -103, -95, -20, -93, -93, 15, 15, 84, 4, 14, -43, -48, -89, 29, -32, -103, -30, -103, -93, -35, -2, -10, -19, 23, 28, -77, -80, 38, -128, 49, 74, -57, -25, -51, 19, 44, -77, 5, 64, -1, -37, 2, -3, 42, -106, -66, 15, -41, -45, -128, 43, 8, -33, 19, -55, -128, -42, -27, -61, -10, -80, -71, -51, 70, -101, 7, -66, 42, -128, 28, -45, -11, 11, -51, -73, -6, -43, -25, 28, -16, -27, -116, -25, -17, -18, -38, 1, -94, 7, -10, -6, -24, -110, 20, 25, -83, -55, -90, -49, 74, -86, -4, -38, -128, -28, -127, -65, 15, -128, -36, 15, -11, -83, -128, -81, -79, -98, 12, -46, 7, -86, -100, -128, -77, -14, 76, 3, -7, 16, -128, 35, -36, -68, -66, -117, -27, -20, -22, -64, -5, 13, -38, -98, -1, -18, -85, -93, 66, -128, 56, -32, -46, 64, 73, 78, 58, 77, -17, -33, -29, 20, -107, -11, 35, 28, -27, -128, -128, -35, -25, -26, 51, 13, -66, -29, -66, -117, -88, -38, -16, -16, 25, 25, -16, -29, 7, -69, -22, 18, -27, 85, -10, -43, -104, 19, -5, -88, 21, -12, -61, -14, -5, -82, 29, -30, -64, 3, 20, -25, -65, -71, -49, -128, -17, 51, -100, 43, 3, -7, 60, -32, -44, -39, -55, -104, -30, -58, -66, -84, -55, -19, -86, -128, -25, 1, 9, -61, -107, 17, 60, -58, -14, 58, -107, -109, 11, -76, 2, 9, 33, -100, -128, -53, -71, 1, -96, -87, 20, 22, -61, -70, -77, -65, -64, 28, 19, -60, 1, 19, -69, -46, 13, -61, -26, 58, 14, -26, 32, 18, -87, 58, 91, -79, -26, -7, -55, -53, -46, 27, -49, 88, 33, -78, 18, -72, -61, -1, -93, 14, 21, -32, -78, -6, 67, -59, 30, 41, 3, -121, -3, 91, -41, 10, 3, 4, -2, 7, -74, -82, -25, -96, 1, -19, -102, -49, 8, 21, -74, 39, -59, -99, -22, 25, -114, -13, 38, -108, -46, 4, 29, -128, -30, -25, -51, 25, -25, -76, -7, 54, -128, 3, -35, 4, -12, -46, -30, -66, -27, -18, -66, -1, -87, -104, 53, -32, -11, -53, -14, -128, 64, -2, -38, -79, 16, -54, -81, -95, -25, -110, 37, 14, -43, -46, 11, -128, 20, -58, -128, -30, 79, 6, -11, 53, -12, 72, 59, -86, -37, -99, -51, 16, 13, 4, 46, -51, 1, 25, -13, 16, -82, -116, -95, -61, -91, 9, 22, -43, -73, 24, 39, -67, 89, 10, -127, -3, -19, -128, 37, 10, -77, 55, -37, -113, -59, -2, 6, -20, 54, -55, -91, 59, 60, -114, 36, -61, -128, -13, -21, -95, -17, 30, 3, -4, 32, -7, -119, 61, -21, -119, 14, 93, -65, -36, -29, -65, -51, 59, -21, -113, 22, 41, -128, -51, -50, -71, 39, -106, -59, -70, -71, -127, 56, 3, -19, -65, 41, 17, -65, -95, -69, -108, 21, -69, -1, 53, 61, -121, -85, 91, -74, -87, 32, -22, -128, -89, -28, -128, -54, -93, -120, -43, -14, -72, 2, 29, -93, -121, 86, 54, -19, -39, -59, -128, -40, -13, -5, -54, 10, -30, -102, -58, 90, -51, -22, -20, -119, -6, -88, -125, 30, 6, -65, -26, 13, 33, -125, 33, 72, -121, 36, 18, -116, 30, -16, -55, -13, -28, -128, 93, -17, -128, -86, -24, -16, -67, -41, -40, -7, -64, 14, -106, -1, -8, -20, -20, -50, -95, 22, 43, 20, -74, -4, 13, -46, 19, 10, -128, -74, -7, -120, -16, -5, -92, -9, 89, 59, -128, 8, -56, -89, 24, -43, -82, 16, -100, -6, 21, 33, 40, 5, 39, 21, -128, 11, 20, -8, -6, -78, -86, 64, -14, -128, 20, 21, 61, 10, 7, -93, -103, -11, -61, -101, 1, -36, -41, -22, -92, -40, 1, 16, 71, 56, 7, -9, -128, -56, -39, -78, 59, 40, -128, 88, 55, -49, 19, -29, -28, -117, 30, -42, -16, 60, -16, 61, -13, -99, -82, 73, 56, -104, 2, -30, -36, -65, 18, -61, -86, -55, -3, 7, 54, 14, -53, -67, -5, -127, 76, -14, -19, -102, 2, -7, -71, 21, -41, -61, 10, 8, -77, 66, -90, -128, 25, 1, -36, -51, -5, 13, -69, 38, -32, -54, -3, -9, -95, -26, -46, -58, -56, -22, -95, -64, -33, -11, -128, -2, -36, -39, -43, 22, -5, 8, -59, -21, -41, -22, 50, -28, 9, -114, -77, 29, -25, -104, -1, -71, -44, 30, -87, -49, -70, -86, -40, 11, 41, -25, -84, -13, -9, -78, -39, -36, -93, 14, -96, -128, 50, 3, -85, -93, 8, -16, -46, 69, -92, 1, -50, 33, -46, -20, -14, -106, -59, -36, 4, -32, 18, 73, -106, 71, 11, -1, -2, 43, -29, 25, 49, -81, 28, 14, 40, -20, 54, 3, -46, -50, -59, -43, 20, 37, -88, -51, 11, -25, -61, 13, -54, -38, -84, 18, -78, -17, 28, -41, -51, 30, -61, -10, -12, -51, 6, 4, -128, -16, -84, -65, -7, 60, 21, -103, -10, 12, -101, -26, 19, -1, -9, -38, 19, -18, -20, 74, -61, 13, -30, -90, -95, 79, -35, -64, 61, -128, -7, -77, 10, -39, -60, -128, 1, 14, -90, -65, 22, 60, -38, 5, 19, -85, -29, 24, -84, 27, 60, 5, -40, 65, 4, -104, -58, 1, -100, -37, -49, -65, 14, -67, -73, -16, -16, -13, 4, 61, 61, -56, 49, -25, -128, 30, -33, -104, -6, -40, -87, -14, -24, -5, -35, 46, -26, -41, 24, 88, -99, -19, -98, -76, 1, -4, -78, -81, 2, -19, -128, 5, -40, -27, 77, -28, 7, 7, 28, -61, -7, -14, -25, -26, -2, -17, -24, 59, 51, -112, 28, 37, -44, 1, -3, -128, -79, -25, -128, 58, 18, 3, -19, 38, 28, -17, -6, -17, -85, -50, -33, -82, -70, 39, -78, 25, 20, -4, -39, -3, 25, -116, 17, -67, -93, -14, -71, -51, -30, 30, 4, -4, -53, -95, -26, -49, -44, -103, -35, -76, -112, 12, -59, -19, 42, 22, -10, 76, -56, -55, -93, -11, 21, -22, -13, -1, -64, 39, 18, -117, -39, 19, -78, 72, -70, -128, 12, -67, -44, -12, -28, -86, 17, 14, 18, -70, 9, -38, -93, 11, -1, -71, -41, -6, -53, -32, -35, -43, -69, 53, -10, -49, 46, 30, 1, -69, 84, -8, -59, -59, -58, -59, 71, 49, -16, -29, -86, -121, 35, 58, -90, 72, 9, 25, -87, -11, 11, -37, 24, -67, -25, -50, 29, -51, -8, -46, -54, -92, -27, 40, -25, 25, 39, -128, 66, -9, -59, -76, -95, -50, 50, -65, 5, -17, 5, 8, -89, -7, 27, -98, 8, -21, -35, 41, -33, -78, 14, 18, -28, -18, -65, 8, -24, -25, 20, -103, -128, -41, -46, 21, 13, -61, -49, -1, -69, -65, 24, -29, -128, -74, 16, -128, -22, -61, -16, -3, -72, -65, 10, -8, -21, -37, 24, -19, -127, 40, 30, -40, -10, 24, -3, 4, -120, 67, 38, 32, -70, -66, -2, 3, -118, -30, 12, -73, -10, -27, -53, -28, -39, -30, -40, 44, -70, -40, 13, 36, -128, -7, 5, -61, 24, -46, -82, 36, -90, -43, 18, 19, 17, -35, -39, 27, -82, 70, -54, -104, 30, 21, -86, 17, 29, -38, 58, -8, -93, 2, -44, 16, -9, -5, -89, -128, -61, -43, -41, -44, 71, -122, -50, -3, -70, -93, -43, -38, -116, 27, -18, -73, -77, -36, -119, -9, -127, -76, -64, -88, -107, -91, 6, 1, -72, 13, 21, -93, -22, -27, -56, -49, -5, -74, 11, -20, 30, -35, -9, -89, -109, -46, -25, -37, -4, -20, -74, 13, -104, -53, -12, -4, 37, -73, 18, -93, -128, -79, -18, -26, -10, 8, 13, 18, -55, -91, -30, -30, -110, -53, -7, -2, -37, -20, 4, 42, 36, -10, -77, 93, -102, -87, -44, -22, 28, -101, -1, -69, -128, 36, 53, -43, 64, -28, -113, 27, -59, 55, 33, -73, -40, -61, 19, 5, -22, -28, -7, 5, 36, -74, -74, 32, -43, -4, -1, 22, -118, -44, -51, 49, -20, 30, 33, -35, -26, 76, -128, -2, -2, -128, 38, 11, -55, -20, -56, 18, -30, 73, 27, 21, -30, 2, -72, 10, -128, -98, -9, 54, -128, -59, -42, -53, -109, 13, -24, -10, -12, -55, -89, -14, -56, -1, 42, -6, -3, -19, 40, -73, -54, 17, -28, -66, -41, 18, -106, -40, -96, -49, 55, -35, 7, -96, -22, -32, -90, -19, 29, 7, 10, 32, -85, 25, -76, -6, -70, -49, -89, -58, 42, 5, -104, -26, -17, 16, -9, -92, -32, 44, -46, -6, 29, -100, -81, -89, 36, -18, -70, -51, 60, -61, -27, -67, -56, -14, -7, -21, -54, -32, -88, -101, 81, 4, -43, -16, 27, 9, 36, -79, -76, 9, -10, -85, 14, 49, -118, -46, 41, 40, -81, 61, -13, 17, -5, -37, -33, 18, -61, 24, 21, -30, -114, -102, 24, 39, -26, -24, 85, -109, 4, -55, -7, 28, -99, 79, -86, 61, -93, -19, 42, -13, -106, 70, -59, -128, -102, -125, -3, 82, -101, -8, -14, 54, -42, -109, -73, -82, -128, -4, 50, -21, -27, -70, -76, -27, -1, -24, 85, 61, -60, -51, 22, -127, -93, -95, -49, 19, -116, -20, -91, -50, -128, 2, -30, -65, -113, 4, -110, -28, -29, -69, -30, 5, 50, -67, -44, -39, -103, -72, 11, -30, -127, -76, -1, 88, -93, -12, 33, 53, 17, -88, -13, 33, -128, -81, 32, -128, -72, -13, -3, -40, -90, -12, -93, 17, -20, -103, -19, -22, -104, -78, 74, -10, -93, -25, 54, 36, -103, 54, 5, -46, -1, -39, 18, 4, -30, 1, -27, 8, -14, -86, 12, 20, -128, 58, 76, 12, -30, -128, -7, -7, -128, 39, -3, -36, -108, -104, -71, 8, -84, 26, -39, -123, -30, -16, -70, 1, -56, -12, -56, 17, -2, -60, -1, -51, -89, -12, -38, -8, 54, -117, 1, -21, -50, 56, 27, 6, 14, -14, 46, -74, -128, 12, 72, -84, -7, -63, 33, 23, 96, -124, -82, 56, -66, -41, -27, -20, -46, -128, 126, 2, 52, -28, -116, -46, 31, -68, -72, 74, -88, -82, -91, -79, -120, -103, -88, -103, -72, -50, -88, -38, 5, -43, -28, -60, -30, -74, 20, -49, -116, -110, -71, 19, 22, -37, -100, -46, 26, -40, -8, -33, -17, -20, 9, -30, -84, -78, -108, -72, 5, -17, -103, 61, -70, -16, -122, 8, -35, -47, 42, -50, -3, -20, -86, -16, -33, 37, -72, 28, -59, -31, -19, -4, -128, -50, 23, -86, -108, -60, -79, -21, -79, 47, -46, -20, 60, -26, -126, -2, -68, -50, 22, -88, -98, -72, -63, -116, -122, -2, -12, -92, 30, -43, 28, -128, -42, 68, -55, -98, -46, 120, -26, -14, -23, 44, -13, 4, -68, 76, -128, -95, -72, 39, -43, -60, -47, -54, -112, -70, -52, -70, -10, 50, 27, -66, -80, -20, -55, -116, 27, 56, -50, 60, -30, -45, 83, 3, -34, -23, -42, -122, -91, -40, -45, -40, 41, -86, -21, -11, -33, -110, 5, 57, 9, -5, -38, -128, 74, 112, -126, -70, 1, -32, -111, -10, -71, -10, 71, 34, -102, 5, -91, -45, 127, -42, -61, -98, -41, -61, -2, 47, -31, -14, -90, 76, -52, 21, 28, -74, 45, -60, -120, -76, -23, -90, 14, 34, 11, -104, -83, 82, -2, 51, -14, -65, 26, 96, -35, -33, -20, -5, -46, -34, -79, -76, -76, -128, -29, -84, -88, -14, -2, -72, -61, 59, 32, -116, -103, -55, -47, -9, 45, -59, -60, 55, 21, -68, -39, -98, -96, -11, -74, -26, -86, -72, -82, -92, 44, -32, -120, -6, -127, 9, -108, -32, -103, -83, 45, 51, -61, 71, -34, -32, -55, -22, -119, 5, -32, -124, -16, -52, 52, -104, -20, -27, -19, 71, -31, -26, 28, -59, -100, 54, -99, -107, 19, -128, -104, 8, 8, 14, -110, 40, 64, 21, -98, -104, -42, 47, 1, -13, -32, -56, 8, -45, -74, -32, -128, -55, -100, -96, -3, -44, -102, 2, -65, -47, 35, -76, -64, -19, 6, 30, -3, 80, -47, -60, -86, -42, -124, 56, -107, -128, -51, 3, -11, -90, -40, -46, -34, 22, 60, -76, -2, -47, 4, -63, -120, -44, -50, 35, -56, -1, 10, -112, -39, -87, 51, 17, -76, 116, 7, 31, -128, 114, 3, -92, -60, -110, -35, 41, -66, 17, -78, -27, -34, -128, 92, 19, -79, -74, -21, -128, -128, -128, -23, -37, -40, -11, -128, -120, 4, -51, -76, -30, -49, -104, -100, -38, 76, -128, 27, -3, -11, -14, 63, -98, 4, -65, -78, 3, -128, -79, 46, -7, -52, -112, 54, -79, -88, -10, -24, -76, -9, -128, -100, -2, -91, -80, -55, -17, -108, -61, -22, -82, -128, 5, 27, -43, 1, -34, -66, -10, -37, -27, -30, 20, -9, -88, -80, -10, -114, -38, -68, -128, -35, 63, -31, 55, -60, -31, 49, 70, -54, -60, -72, -72, -12, 27, -50, -51, -27, -43, -84, -68, -98, -59, 40, 68, -104, 19, 14, -32, -124, -32, -72, -8, 9, 80, 111, -3, -123, 41, 83, -72, -19, 2, 72, -70, -71, -72, 26, 80, 24, 116, 108, 19, -10, 99, 112, -47, -120, -112, -18, 52, -80, -6, -3, 127, -21, -126, -41, -82, -32, 24, -38, -13, -27, -76, 24, 42, -65, -6, 13, -51, -19, -68, -47, 8, -34, 74, 55, 9, -83, -44, 45, 42, -82, 37, -22, -72, 43, 10, -23, 7, 19, -72, 6, -21, -128, -128, -72, 127, -103, -4, -78, -76, 28, -102, -63, -43, 78, -30, -41, 55, -33, -108, 72, -56, -61, 55, 31, -31, -37, -82, -111, -7, -21, -76, -7, 56, -91, 104, 23, -128, -27, 26, 2, -50, -17, 61, -76, -54, -45, -83, -26, 10, -29, -30, -37, -64, -100, -41, -71, 106, -23, 70, -96, -104, -49, 59, 114, 3, -100, 72, -14, 16, -104, 51, 32, 110, 3, 59, 127, 30, -29, 11, 26, -66, -108, -51, -13, -4, -86, -35, 14, 72, -24, -122, 32, -12, -82, 80, -33, -112, -76, -1, -35, -37, -44, 26, -4, -60, 44, -79, 100, 49, -72, 49, -23, 11, -44, -12, -24, -32, -119, -49, 10, -119, 14, -98, -11, 60, -110, 127, 18, 12, 96, -65, 13, -14, -43, -4, -1, -35, 18, -26, -44, -1, 112, 9, 35, 10, -72, -20, 82, 64, -24, -11, 37, -38, -94, 94, -63, -16, -88, -54, -5, 56, -107, 111, -6, -64, -28, -23, 21, 7, -41, 76, 14, 72, -35, -18, -41, -2, -111, -70, -7, -60, -63, 55, -42, -86, 51, 91, -88, 12, -72, 65, -44, -128, -104, 66, -99, -78, 68, -34, 60, 49, 42, -64, -95, -21, -70, 88, -88, -76, -90, 95, -14, 41, -63, -34, -60, 28, 74, -45, 86, 1, -128, 3, 14, -49, -128, -34, -7, -47, 3, -2, 13, -30, -9, -128, 41, -50, -51, 124, 29, 34, 31, -76, 8, 37, -9, 68, -8, -68, 42, -68, 1, -52, 5, 43, -21, 22, 70, -5, 22, 20, -24, 57, 23, -6, 108, -122, -110, 9, -8, 17, 32, -57, 92, -52, -33, 59, -64, -61, -71, -128, 94, 12, -26, 1, -68, -46, -8, 4, -6, -56, 24, -11, -41, 26, -10, -95, -86, -41, -30, -21, 80, -124, -14, -16, -33, -6, 70, -17, -94, -1, -33, 39, 5, -128, -59, -37, -49, -32, -94, -95, -128, 127, -34, 3, 127, 27, 71, 70, 18, -102, -35, 13, -19, 54, -27, -23, -91, 94, -44, -4, -21, -27, -20, 49, 23, -96, -66, -8, -103, 61, 51, -37, 116, -108, 13, -31, -46, -18, 46, 65, -40, -120, 20, -16, -70, 44, 31, -13, 16, 64, 71, -9, -71, 2, -29, 127, 55, -82, -127, 3, -87, -1, 43, 76, 60, -51, -43, 38, 18, 7, -46, -124, -3, -43, -39, -22, -50, -4, 40, -42, 95, -82, -28, 33, -116, -16, -30, -102, 38, -47, -28, -44, -10, 4, -66, -72, 76, -49, -16, -2, -86, -20, -72, -50, 12, -43, -59, 120, 90, -128, -47, 76, -119, 17, -11, -17, -92, -128, -128, -8, 46, -2, 72, -39, 29, -128, -76, -127, -102, 22, -124, -47, 10, 6, -111, 66, -18, 66, 63, 41, -28, -47, -68, -80, -29, 127, 4, 46, 82, 1, 22, 13, -12, -39, -47, -17, -98, -45, 37, -43, -30, 55, -30, 3, 110, 23, 20, 34, 68, -38, 91, 31, -20, 107, -10, -10, -110, 65, -72, 6, -70, -44, 50, 90, 32, -99, -55, 72, -87, 76, 56, -40, -6, -61, -1, 29, -12, -39, 1, 96, 54, -65, -51, -55, -104, 65, 1, -22, 126, -99, -71, 35, -20, 33, 43, -52, -87, -57, -49, -49, -54, 90, 28, 19, 127, -9, -76, -128, -50, -26, -52, -21, -119, -51, -44, 16, -128, -39, 21, -45, 114, 12, -33, -40, -4, -80, -37, -7, -9, 22, 82, -104, -16, -126, 24, 41, 127, 95, -128, 54, 5, -128, -90, -16, -18, -108, 100, 11, 84, -47, -5, -17, 99, 126, -100, -88, 37, 87, -46, 42, -39, 23, 3, 46, 59, -127, 39, 3, 1, -5, -5, -32, 52, -49, 12, 59, 6, 12, -80, 17, -16, 127, -17, -104, -107, 55, -3, 88, 92, 39, 37, 127, -70, 127, -59, -71, -76, 127, 9, -61, 104, 68, -6, 126, -41, 46, 71, 79, -5, -13, -21, 27, -5, 38, 17, -55, 91, -72, 26, 45, 7, -56, 2, -22, -71, -103, -70, 26, -84, 91, -27, 19, -16, -28, 3, -91, -128, -3, -29, -76, -96, -96, -114, 40, -34, 39, -11, 103, 116, -124, 11, -50, -103, 17, -37, -16, -29, 33, 31, -42, 64, -128, -1, 90, -59, -98, -46, 2, 79, -8, -7, -112, 108, 19, 68, 30, 13, -5, -51, 11, -95, 11, -110, 4, 10, 6, 18, -26, 65, 59, 71, -90, 112, -90, 46, -60, -128, -60, -32, 60, -21, -128, 2, 55, 12, 29, -5, -6, 74, -96, 26, -28, -82, 31, -21, 50, 39, -72, 8, 38, -44, 61, -128, -43, -65, -124, 38, -68, -66, 35, -30, 76, 126, 22, 1, 23, 108, 7, -5, 19, -60, 39, -41, -31, 110, 11, 123, 127, -51, -8, 35, 127, 43, -76, -112, -21, -128, -23, 2, 127, 71, -52, 7, 127, 7, 104, 27, -90, -3, -100, -124, 61, -64, 26, -87, 64, 17, 1, 111, -59, -66, -6, 37, -3, -65, -103, 41, 27, 32, 127, 11, 10, 38, -28, -13, -3, 108, 10, 10, 55, -107, 82, 28, 7, -12, 40, -68, 86, 65, -41, -47, 51, 47, 8, -3, -39, -3, 127, 41, 88, 27, 1, -18, -70, -92, -26, 40, 5, 79, -8, 5, 76, 104, 22, 50, -65, 44, 42, 57, -40, -79, -88, -31, -14, 82, 34, 8, 100, 68, 68, -80, 71, -94, -23, 24, -57, -68, -40, 3, -22, -74, 27, 54, 96, 108, 23, -124, -4, -17, -31, 86, -124, -14, -84, -28, 40, -100, 39, 30, 13, 98, -128, -30, 13, -6, 46, 14, -13, 65, -60, 22, 66, -128, 6, -16, -128, 80, -76, -112, -13, -99, -86, 26, -21, 96, -128, 40, -116, -98, -26, -46, -94, 32, 17, -61, -50, 102, -1, -24, -76, 26, -94, 46, 89, -80, -12, -74, -128, 50, 39, -95, 73, 6, -2, -118, -22, 50, -15, 27, 9, -17, -65, 55, -107, -10, 42, -95, 44, -44, -107, 40, -15, -24, 19, -55, -55, 76, 102, 93, -72, -13, -13, -128, 5, -5, -52, 87, 75, -74, 127, -3, -101, 88, -48, 104, -128, 4, -13, -128, -8, -47, -89, 61, 22, -60, 22, -51, -99, -10, 35, 113, -26, 66, -3, 2, 38, 27, -27, 120, 44, -116, -32, 13, -128, 68, -34, 84, -126, 62, -19, -83, 40, 13, -89, -128, 127, -2, -113, 17, -49, -30, -76, -48, 41, -62, 29, -75, -41, 20, -101, 80, -40, -30, 57, 27, -122, -98, -32, -32, 90, -24, -22, -78, 65, 74, -19, -99, 88, 127, -42, 84, -69, -88, -114, -103, -97, 49, 55, -48, -31, 11, -92, -35, 95, 91, -128, -36, -26, -115, 8, -81, 65, 31, -8, -6, -13, 67, -54, 62, 42, 16, 67, -51, -75, -20, 27, -128, 5, -5, -52, -99, 51, -38, -46, 97, 36, -125, 108, -65, 37, -126, -47, -128, -73, 34, -4, -38, 17, -46, -93, -78, 98, -16, -67, 16, 89, -34, -42, 55, -54, -92, -21, -52, 36, -24, -127, -10, 102, -68, 104, 27, -55, -110, 17, -72, -128, 16, 45, -74, -6, 34, -105, -13, -65, -8, -128, -12, -24, 88, -55, -27, -44, -37, -24, -125, 72, 80, -15, 47, 22, -73, -29, 17, -20, -76, -22, 27, 86, 13, 127, -61, -4, 21, -121, -70, 49, -70, -23, 27, 19, -103, -72, 122, -36, 31, 35, -73, -27, -47, -80, -10, 127, -10, -35, 40, 13, -12, -5, 57, -52, -67, -5, -20, 16, 3, -128, 6, 87, -105, -70, 17, 48, -37, -9, 44, -49, -37, 46, -128, 3, -128, -12, 19, 30, -105, -75, -1, -38, -38, 67, -93, -121, 2, -125, -31, 31, -60, -98, -22, -41, -67, -95, -1, 38, -32, 70, 40, -69, 21, -118, -31, 20, -68, -105, 24, -27, -117, 1, 46, -128, 5, -5, 123, -128, 50, -1, 5, 37, -61, -91, -66, 16, -50, -107, 69, -128, -62, -21, -44, -34, -57, -127, -6, -52, -127, -55, -6, -19, -26, 6, -19, -19, -128, -66, -111, 68, -37, -31, -54, 17, -76, -91, 81, 57, 94, -73, 127, 52, -128, 1, -128, 52, -27, -48, 10, -13, -42, -30, 96, 111, -105, -40, -76, 16, -6, -31, -46, -62, 16, -125, -35, 44, -117, 19, 44, -39, -72, -34, -5, 23, -97, 19, -17, 72, 52, -128, -105, 9, 26, -76, 16, -23, -111, -35, -34, 34, -98, 12, -60, -6, -37, -10, -103, 23, -113, 6, -16, -76, -20, -75, 38, 8, -62, 26, -35, -101, 44, -75, -66, 32, -2, -50, 22, 21, 103, -87, 42, 92, -92, 11, -4, -9, -13, 1, -69, -36, -128, -80, -15, 38, 78, -40, 24, 9, -52, -41, 32, -21, -103, -69, -23, -89, -54, -72, 16, -23, 124, -39, 1, -36, -91, -15, 84, 46, -50, 91, -96, -27, -55, 72, -12, 55, -126, -38, -128, -36, -94, -67, 126, 52, -26, -27, -117, 66, -57, -107, 111, -55, 127, -120, -20, -21, -88, 35, -12, -66, 15, -29, -3, -49, 127, -111, 27, -110, 117, -46, 47, -26, -60, -3, -67, 78, -27, -62, -5, 9, -40, -39, 55, -1, 123, 4, -11, 107, -81, -68, 23, -23, -17, 92, -86, -86, 67, -36, -23, 24, -3, 4, 29, 48, -80, 40, -80, -54, -13, -17, -90, -70, -65, -1, -27, 11, 126, -128, 48, 123, 2, -32, -39, -88, 57, 13, -45, 13, 124, -29, -32, -8, 121, -2, 36, -73, -40, 4, -57, -49, -102, -105, -49, 80, -120, -19, 3, -6, 118, -30, -24, -57, -45, -11, -83, 65, -6, 76, -128, 91, 127, -17, 127, -26, 110, -37, 110, -1, -123, 4, 90, 48, -47, 113, -31, 24, -2, -2, -78, 75, -26, -50, 37, -6, -9, 41, -5, 51, -5, 122, -51, 35, 54, 54, -10, 105, -113, 78, -36, 34, -107, 3, 13, 30, -13, 41, -92, 17, 62, -45, 8, -2, -41, -107, -74, 76, -37, -24, 57, -121, -55, 80, -22, 29, 103, -13, -47, 19, -51, -15, -26, -76, -20, -61, -16, -117, -22, 37, 17, 61, 127, -99, 6, -36, 39, -76, -29, 57, -49, 16, -30, -52, 44, 107, -17, 15, -27, -76, 6, -35, -62, -60, -32, -11, -54, -6, -3, -60, -69, 72, -69, -69, 41, -32, 75, 55, 94, 11, 6, -20, -60, 27, -61, 13, -6, 6, -41, 39, 3, -55, 30, 84, 31, -121, -60, 1, -83, -26, 72, 127, -19, 42, -15, 8, -1, -17, 120, 13, 103, -84, -86, -12, -128, -49, 113, 66, -8, -113, -20, 49, 83, -105, 19, 89, 50, 46, 67, 23, -15, 90, 78, 13, 21, 84, -97, -8, 54, -122, -30, -17, -83, 73, -49, 40, -108, -29, -66, -128, 52, 76, -81, 29, -61, -119, -45, 15, -72, 4, 19, -76, -81, -68, 1, 10, -27, -91, -65, -51, -76, -3, -76, 37, 89, 89, -62, 10, -27, -62, -10, -128, 75, -46, -23, 52, -108, -36, 47, -19, -86, -117, -6, -128, -46, -55, -15, -99, -128, -128, -52, 5, 108, -52, 10, -39, 86, 22, 32, -48, -114, 51, -69, 46, 5, -89, -120, 91, -6, -34, 111, 73, 90, -93, 90, -57, -72, -55, 127, -11, -32, 113, -113, -36, -128, -40, 16, 16, -73, -128, 1, 66, 10, 4, 105, -113, 24, -80, -91, 20, -1, -69, 29, 91, -55, 31, 49, -36, -125, -1, -8, -115, 3, 10, 1, -22, 50, -74, -20, 70, -61, 127, -30, 16, -62, 50, -16, -99, 48, 62, -8, -76, -99, -92, -30, -30, -99, -20, -48, -128, -2, -9, 9, -105, -38, 127, -10, -1, -75, -118, 37, -19, 70, -61, -10, -69, -34, 5, 19, -60, 98, 48, -23, 27, -90, -60, 29, -19, -78, -29, 49, -55, -48, -20, 27, 4, -103, -21, -39, -31, 127, -21, 5, 4, 73, -104, -11, -55, -86, 127, 98, 1, -27, -41, -70, -69, -60, 102, 49, 48, 127, -94, 84, -72, -50, 2, -107, 67, 6, -116, 9, 45, 29, -57, 114, -2, 44, -37, -1, 13, -75, -13, 46, 78, 16, 116, 6, 31, -1, -123, 21, 54, -37, -128, -27, -5, -41, 20, 62, 91, 2, 108, -116, -110, 72, -89, 1, -20, -67, -35, -48, 22, -75, 26, 32, 127, -11, -5, -36, 80, -76, -76, 30, 102, -46, 16, -4, 94, -93, 38, 1, 92, -35, -4, -45, -35, -41, 1, -31, -69, -89, -42, -39, 54, 4, 2, -2, -24, 75, -128, -61, 5, -21, -75, -19, -6, -89, 35, 90, -51, 19, -6, -61, -50, -97, -49, -111, 15, -111, -74, 75, -42, 24, -47, -3, -125, -49, -35, -11, -42, 89, -16, -11, 93, -55, 32, -11, 127, -92, -31, 24, -1, -86, 69, 76, 127, 69, 61, -128, 60, -128, 96, 57, 48, -73, -84, 55, 12, -114, -3, 20, 67, -32, 124, -93, 11, -72, 51, 62, -17, -128, -65, -51, -26, -65, 2, 3, 115, 15, 69, -12, -1, 96, -41, 16, 105, -103, -105, 57, -29, -17, -35, 49, 76, 27, 22, -60, 42, -81, -122, 6, 127, -70, 6, -51, 102, -51, -13, 8, 94, -5, 127, -120, -68, -46, -13, 27, -19, -51, -13, -27, 95, -72, -20, 6, -70, 111, 55, -13, 13, -125, 90, -16, 50, -35, -48, 19, -72, -30, -39, -87, -62, -99, -128, -35, 39, -120, -27, 6, -67, 93, -102, 8, -103, -107, -93, 2, -19, -90, -67, 2, 83, -114, 24, -60, -52, 90, -92, 102, -20, -76, -19, 78, 122, -83, 86, -128, -47, -128, 84, 3, -65, 23, -125, -119, 50, -42, -69, -10, 65, -72, -17, -128, 69, -12, 76, 27, -35, -84, -52, 34, 46, -93, -31, -4, 104, 65, -126, -76, -40, -24, 17, 13, 9, -97, -75, -21, 30, -107, -36, 35, 92, -122, -65, -115, 9, -36, 75, -16, -88, 3, -70, 61, 111, -38, 21, 10, -102, -54, -88, 21, -70, -41, -12, -10, -67, -40, -69, -104, 44, -103, 34, -6, -35, -108, -49, 17, 15, -120, 44, -86, -92, 6, -81, -16, -68, 16, 74, -3, -6, -15, -67, -65, 8, -67, 117, 38, 119, -4, -30, -30, -41, -99, -69, -55, -40, -41, -75, -83, 127, -108, -24, -24, -35, -70, 83, 76, -4, -32, 8, 30, -9, -10, -13, -96, 31, -105, -37, -20, -76, -1, 32, 127, -20, -73, 50, 8, -103, -91, -104, -39, 35, -121, -21, 66, -72, -101, -38, -22, -80, -1, -32, -16, -101, 22, -17, -113, -49, -65, -49, 6, -44, 15, -98, 20, 67, -16, -36, 80, -92, -60, -86, -83, -51, -72, 76, 65, -86, 122, -16, -3, -32, -128, -8, -12, -44, 38, -55, -104, -57, -12, -12, -41, -45, 127, 12, 44, 20, -70, -32, 13, -108, 107, -40, -126, -4, -17, 8, -23, -73, 113, 6, 115, -38, -42, 31, -11, -27, 15, -89, -76, -23, -122, -86, 15, 1, 21, -127, 40, -81, -65, -116, -12, 10, 89, 23, 2, -1, 14, -15, 5, 67, 15, -88, 79, 23, -3, 73, 13, 43, 121, 24, 1, 2, -5, -10, 5, 56, 43, 21, 67, -38, -3, 32, -13, 43, 58, 58, 1, -1, -50, -24, -18, 46, 23, 84, 5, -21, -8, -41, -10, 21, 43, 67, 3, 15, -27, -3, 14, -13, 18, 72, 1, -49, -14, -1, -21, 10, 127, 21, -28, 23, -24, -33, 14, 1, 2, -14, -3, -8, -12, 1, 1, 19, 113, -32, 10, 32, -20, -8, 3, 3, -2, -35, 1, -48, 3, 21, -8, 20, 67, 1, 1, -1, -19, -10, -14, 94, -12, 28, -5, -46, -12, 2, 10, 19, 14, 13, -20, -46, 1, -10, 15, 68, -1, 88, -8, 1, -27, 18, -18, -8, 106, -3, 21, 38, 1, 49, 8, 48, 18, -64, 56, -1, -1, 19, 8, -3, 124, 52, 1, 27, 21, -14, 21, 21, -12, -72, 12, 24, -33, 14, -13, -18, 37, 127, -3, 19, 18, 8, -10, 15, -14, 35, 35, -23, -3, -23, -19, 10, -8, 119, 1, 10, 3, -5, -18, -2, 20, 58, 38, -5, -27, 19, -3, 1, 46, 19, -3, 72, 15, -13, 13, -1, -1, -1, 103, -1, 1, 2, -12, 40, 64, 3, -2, 62, 15, -37, 19, 52, 1, -12, 32, -45, -5, 85, -8, 56, 14, 8, -27, 49, 18, -1, -13, 58, 27, -24, 10, -48, -5, 40, 1, 8, 15, 5, -19, 13, -21, -2, -8, 112, -2, 58, 8, -35, -13, -14, -12, 1, 19, 109, -2, 19, 1, 48, 8, 58, -20, -38, 23, -75, -2, -5, -5, -10, 56, 46, 19, -13, -2, -12, 15, 119, -28, -35, 64, -128, -21, -56, -3, 3, -3, -45, 8, 13, 24, -20, 5, 127, -21, -32, 28, -41, -33, -35, -10, 46, -41, -3, 32, -18, 15, 5, -8, 85, -14, -2, -18, -10, -18, -3, -5, -2, 14, 24, 21, -18, -2, -3, -13, 120, -20, -58, 13, -13, 5, 89, -12, 13, 35, 28, -18, 28, 8, 2, 1, 127, -5, -14, 41, -56, -23, 56, -35, 18, 23, 27, -2, 49, 14, 1, -5, 89, -1, -32, 111, -5, 14, 49, -28, 23, 15, 20, 3, 49, 46, 2, 52, 8, -13, -23, 103, 1, -32, -12, -12, -8, -79, 127, -1, -15, -21, 27, -2, 3, 12, -37, -21, -121, 1, -13, -5, -1, -92, 82, -8, -15, -5, -8, 1, 12, 5, -50, 75, -46, -8, -23, -1, -13, -128, 56, -2, -40, 3, 3, -14, 50, -19, -72, 50, -49, -23, 18, -21, 12, -48, 121, -12, -15, 35, -12, 24, 79, -40, -49, 1, -21, -14, -18, -8, 3, -43, 127, 15, -20, 10, -1, 3, 72, -20, -50, 1, -37, -13, 38, -5, 12, -79, 62, 10, -13, -33, -1, 5, 64, -49, 5, -19, -24, -19, 76, -27, 28, -1, 5, -13, 41, -8, 5, -13, 49, -19, -13, -1, -35, 15, 64, -5, 35, -52, 27, 3, 3, 21, 12, 19, -1, -1, -97, 109, -14, 13, 35, -18, -5, -46, 92, -3, -32, -58, -13, 10, 40, -12, -12, -46, -38, -14, 60, -1, 10, -56, 82, -28, 5, -41, 3, -8, 20, -8, -18, -28, 12, 8, 14, -1, 18, -13, 89, 2, 8, -21, -3, 8, 78, 5, -58, 2, -89, -13, 37, -15, -8, -12, 23, -12, 1, 2, -13, 20, 98, 1, -56, 67, -84, 3, 58, -32, -13, 13, 52, -32, -35, 3, -19, 5, 21, -2, -32, 99, -37, -2, 28, -12, 10, -41, 56, -2, -43, 14, 24, -1, -62, -27, 23, 8, -12, -1, 60, -13, 12, -23, 13, 10, -19, 1, 18, -15, 13, 1, 3, 1, -8, 2, 96, -20, 41, -35, -3, 5, -8, -20, 15, -13, -2, -1, -27, -18, -27, 2, 41, -14, -2, -38, 72, -10, -28, -40, -19, -14, 60, -8, -3, -35, 18, -10, 40, -5, 3, -76, 79, 21, -15, -28, -2, 3, 43, -12, 13, -19, 27, -1, 15, -1, 23, -38, 33, 2, 15, -48, 5, 18, 50, 10, -37, -19, -56, -3, -40, 1, 3, -20, -14, -20, 24, -35, -19, -10, 28, 12, -67, 1, -56, -14, 2, -8, -18, -3, 20, -12, -8, -8, -27, 5, 41, 12, -24, -18, -48, -2, 8, 14, 23, -21, -1, -37, -33, 12, -14, 2, 94, 13, 15, 78, -2, -14, 32, -2, 27, -27, -19, -2, -37, 13, 3, -1, 124, -5, 48, 58, -2, -14, 107, -18, 27, -37, 8, -1, 1, -8, -14, -1, 106, 8, -3, 79, -1, -10, 2, -23, -5, -43, 38, -2, -24, -19, -3, 2, 56, 18, -41, -12, -101, -13, -52, 13, -5, -40, 3, -5, -41, -5, 15, -21, 82, 13, 12, -3, -110, -15, -97, 3, -14, -35, 45, 2, -10, -2, 20, 2, 76, -1, -28, 15, -38, 1, -119, -1, -5, -28, 32, -1, 23, -5, -20, -3, 79, -3, -21, 20, -24, -33, 24, -1, -5, 3, 5, -27, 27, 10, -14, -24, 50, 14, -56, 46, -27, 2, 12, -19, 12, 52, 24, -27, 56, 13, 1, -10, 49, 38, 1, 92, -18, -14, 68, -12, 38, 43, 19, -18, 40, 40, 1, -12, 103, -15, 21, 127, -5, -10, -20, -35, 12, 56, 2, -8, 20, 46, -45, -14, 13, -2, 20, 127, -2, -35, -20, -2, 10, -33, 33, 15, -45, 14, -41, 15, 1, 35, -48, 62, -128, -12, -68, -12, 1, -64, -3, -8, -18, 3, -21, -8, -2, -13, -2, 40, -128, 8, -112, -2, 14, -127, 10, -20, -5, 3, -13, 12, -13, -14, 18, 3, -46, -5, -78, -1, 3, -85, 38, -1, 8, -19, 18, 15, -56, -13, -23, 32, 12, -8, -41, -24, 3, -60, 23, 1, 56, -12, 20, 3, -19, -15, -56, 65, -15, -23, 8, -37, 35, -24, 15, 1, 121, 13, 14, 20, 2, 3, -56, 76, -12, -3, 110, -18, 23, 12, 18, -5, 123, 72, -14, 12, 74, -15, 1, 24, -12, -15, 52, -8, 23, -21, 37, 5, 46, 64, -24, -2, 127, -1, -13, 127, 2, -15, -38, -27, 2, 2, 15, -12, -14, -10, -15, 18, -3, 49, -23, 24, -107, -3, -24, -23, -1, -58, 43, -12, -3, 3, -5, 2, -12, 1, -40, 24, -72, -3, -58, -3, 24, -111, 37, -5, -21, 24, -19, -3, 12, 8, -1, -32, -60, -20, -43, 1, 8, -98, 28, -10, -27, -33, 8, -14, -41, -1, 56, 24, -46, 5, -85, -10, -8, -82, 28, 19, 56, 3, 38, 14, -65, -2, 21, 21, 5, -19, -12, -18, 12, -43, -40, 19, 120, -3, 40, 12, -96, -12, -112, 64, 21, 8, 62, -13, 21, -24, 19, 24, 127, 14, -19, -3, -123, 27, -121, 96, -50, -18, 96, 1, 27, -38, 19, 19, 62, 24, -58, -15, -109, -28, -65, 50, -28, 1, -23, -10, -14, 1, 1, -14, 13, -5, -10, -2, 8, 41, -37, 12, -101, -20, -49, -15, -12, -18, 23, 21, -14, 19, -40, -18, -2, 23, 21, 48, -76, -12, -58, -13, 20, -23, 19, -13, -52, 35, -15, 8, 40, -1, -10, -1, -68, -20, -56, -21, 2, -48, 43, -10, 2, -8, -18, 15, 52, -15, 20, -85, -43, -5, -92, 5, -18, -64, -60, 1, 37, -45, 40, -1, -19, 1, 85, -99, 23, -10, -48, -21, 14, -88, -37, 1, 116, -56, 37, 12, -73, 3, 56, -14, 40, -13, 41, -2, 3, -28, -8, -12, 99, -18, 35, 12, -128, 27, -120, 75, -27, 8, 127, -3, 19, -40, 32, -12, 101, 19, -65, 3, -128, 35, -124, 40, -68, 1, 35, 2, -19, -3, -24, 13, 1, -5, 5, -18, 37, 15, -73, 32, -106, -10, -23, -5, -5, -33, -35, 10, 19, 14, -32, -20, 38, 21, -41, 18, -127, -1, -52, -24, 12, -10, -97, -2, -1, 12, -28, -12, 2, 2, -15, 33, -76, -13, -58, -35, -5, -23, -38, -45, -1, 3, -68, -19, 23, 20, -19, 38, -23, -20, -50, -15, -2, -56, -32, -40, 10, 18, -15, -2, 41, 28, 58, -46, 43, -18, -88, -3, 15, -103, -10, -5, 41, -41, 13, -5, -32, 18, 103, -50, 127, -18, 50, -28, 1, -82, 24, -35, 19, -72, 14, 23, -97, 40, -37, -62, 56, -12, 127, 1, 23, 12, 37, 8, 43, -79, -99, -14, -128, 14, -84, -43, -28, -32, 121, -18, -1, -40, 13, 32, -1, -14, 3, 15, 33, 32, -23, 28, -76, -8, -24, -5, 13, -10, 41, 3, 2, 10, 5, -1, 58, 43, -13, 33, -121, -15, -45, -43, 3, -12, 38, 35, 24, 13, 8, -32, 56, 21, -19, 15, -99, -13, -97, -18, 10, -1, -92, 8, 23, 14, -2, -28, -2, 20, -15, 24, -123, -20, -96, 3, 21, -75, -107, -21, 1, -1, -40, 38, -12, 3, 19, -8, -1, -10, -68, -46, 10, -120, -88, -97, 12, -3, -78, 45, 12, -2, 99, -24, 123, -5, -19, -28, -8, -128, -45, -73, -10, -45, -48, 37, -33, 1, 64, -94, 88, -2, 98, -21, 5, -24, 13, -68, -15, -113, -96, -18, -40, -1, -73, -128, -5, -21, 84, 30, 9, -101, 59, 25, -43, -91, -24, 45, -65, -10, 67, -98, -41, -5, -41, 56, 20, -100, 5, 32, -13, -115, 1, 30, -75, -48, 67, -67, 1, -4, -91, 30, 23, -68, -17, 3, -13, -55, 101, 17, -34, 17, -24, 1, 39, -2, -23, -10, 11, -91, -21, 21, -21, -5, 74, -25, -20, 1, -68, 1, 32, -5, 14, -24, 32, -128, -6, -1, -9, -75, 3, -21, 18, -1, -70, 9, 81, -7, 27, -13, 15, -96, -26, 7, -26, 7, 39, 20, -36, 27, -59, -24, 69, -30, 48, -35, 10, -24, 1, -13, 41, -4, 73, -6, -36, -7, -5, -13, -2, -30, 24, 3, 10, 39, -6, 6, 2, 6, 60, -11, 44, -20, 18, 2, 35, -11, 60, -4, 18, -106, -5, -41, -71, -115, -39, 19, -15, 17, 48, -4, -39, 64, -61, 17, 17, -94, 9, 7, -64, -70, -9, 19, -69, 15, 50, -9, -128, 5, -101, 45, 35, -87, -128, 9, -45, -69, 25, 10, -24, -1, -6, -1, 32, 45, -89, 13, 25, -96, -128, 21, -63, -87, 44, -13, -48, 39, -111, -34, 45, 30, -56, -1, 27, -39, 82, 27, -43, -100, 3, 3, -17, 4, -92, -88, 61, 14, -25, 1, 3, 6, 119, -17, 11, -60, 24, -17, 44, 30, -40, -24, 71, -17, 7, -30, 18, 1, -18, 3, 18, -68, 19, -19, 9, -10, 2, -1, 35, -32, 36, -5, 21, 10, 18, 5, 7, -43, 26, -7, 67, 11, 14, -5, 19, -36, 56, 1, -21, -37, -128, -60, -63, -11, -87, 30, -15, 55, -3, 6, -87, 35, -61, 56, -2, -106, -109, -14, -69, -19, 19, 21, -39, 23, 37, -3, -48, 43, -84, 41, 3, -119, -81, -81, 30, -44, 11, -1, -36, 50, 32, -40, -32, 30, -61, 20, 3, -50, -14, -40, 15, -37, 10, 21, -30, 13, -24, 13, 10, 21, -122, 4, 25, -44, -40, -63, 11, -27, 30, -14, 3, 7, -60, 45, 19, -19, -106, -25, 24, -4, -9, -27, 18, 14, 44, 13, -3, 43, -84, 27, 39, 19, -5, -30, 23, 30, 4, 24, 27, 19, 40, -6, 71, -1, 2, 5, 36, -3, 27, -3, 18, -18, 45, -13, 44, -18, 67, -39, 127, -43, 59, -35, 14, -26, 20, -10, 30, 32, -128, -3, 9, -21, -75, 4, 6, 32, -20, 17, -128, 27, -82, 13, 5, 19, -86, 11, -39, -70, -6, -30, -26, 87, 19, 30, -128, 26, -128, 45, 20, 84, -44, -45, 17, -55, -11, -20, 3, 94, 69, -24, -9, 30, -128, -13, 24, -78, -20, -63, 19, -74, 2, -10, -75, 48, -7, -26, 20, -6, -115, 6, 44, 18, -103, -9, -10, -25, 64, 21, -45, 23, -7, 6, -6, 9, -69, -30, 40, 100, -60, 9, 30, 1, 50, 20, -74, 41, -3, -6, 25, 14, -1, -36, 4, 44, -40, 27, 15, 24, 30, -26, 101, 1, 20, 21, 25, 1, 15, -19, 37, 37, 30, 18, 20, 14, 37, 2, 91, -13, 65, -9, 25, -9, 17, 27, 27, 13, -74, 17, -25, 50, -9, 39, -14, 68, 6, 4, -121, 50, -102, 6, 35, -61, -55, 56, -21, 14, 9, 10, -40, 94, 15, 30, -117, 35, -128, 15, 25, -56, -39, -1, -10, 14, -6, 4, -39, 80, 73, 36, 9, 41, -128, -3, 30, -53, -6, 26, -6, -3, 10, -19, 7, 41, 21, -36, -11, 18, -113, -1, -4, 3, -30, 25, 35, -21, 4, 23, 74, 30, -30, -91, 6, 32, -34, -18, 7, -2, -11, -2, 73, -23, 11, 2, 9, 59, -71, -48, 1, 23, -5, -11, 41, -11, -11, 19, 70, 19, 11, 17, -30, -24, -61, -20, 1, -6, 27, -19, 43, -23, -3, 17, 10, 37, 53, -17, -20, -14, -74, 48, -2, -2, -5, 13, 35, 55, 21, 26, -69, 60, -11, -3, 70, 56, 53, 21, -88, 35, -50, 15, 3, 11, 1, 18, -114, 45, 7, 5, 84, 115, -11, 37, -106, 32, -91, 4, 19, -3, 23, 27, -102, 56, 23, -3, 48, 65, 32, 3, 13, 50, -100, -9, 9, 64, 30, 1, -24, 23, 11, 4, -30, 65, 10, 80, 17, 27, -44, -7, 24, 18, 13, -7, 10, -30, 2, -13, 4, 17, -21, -60, 4, 9, -34, -30, 23, 6, 15, -24, 7, -43, 3, 11, -10, 20, -30, -128, 9, 7, -44, -15, 11, -18, -30, -10, 48, -41, 1, -2, -30, -34, -32, -106, 37, 18, 6, -15, 36, -39, 34, 3, -1, -48, 40, 15, -11, -10, -35, -21, 6, 11, -11, 10, 13, 114, -10, 85, -32, 86, 25, -1, 86, -1, 20, 2, -119, 43, -39, 18, 10, 19, 45, 61, -91, 37, 23, -18, 103, 101, 6, 63, -81, 35, -98, -4, 7, 13, 35, 37, -53, 44, 10, -2, 115, 10, 53, 84, 59, 40, -74, 18, 43, -35, 26, 26, 15, 21, 32, 9, 69, 2, 26, 20, -10, 18, -27, 20, 19, -20, 26, -5, 67, -3, 37, 1, 24, -2, -41, -2, 24, 44, -19, -45, -1, -89, 6, -48, 27, -2, -19, 1, 43, 19, -20, 40, 17, 25, -26, -39, 32, -86, 23, 1, 26, -1, -18, -18, 13, 4, -32, -128, 41, 1, -30, -10, 20, -102, 7, 5, -4, -48, 13, 19, -50, 11, -1, -128, 13, -1, -34, 6, 3, 70, 35, 96, 27, 81, 106, -4, 69, -4, -53, 14, -101, 35, -64, 15, 14, 19, 19, 85, -3, 63, 50, 6, 69, 41, -30, 59, -36, 39, -115, -21, 13, -18, 81, 44, -30, 91, 84, 10, 81, 30, 17, 26, 55, 30, -92, -2, -1, -78, 73, 50, -1, 44, 63, -14, 21, 18, 30, 35, 2, 27, -55, 5, 25, 3, 17, 17, 50, 32, 55, 4, -20, 40, -83, 10, 48, 19, 4, -17, 10, 121, 20, -13, 64, 41, 44, 9, -17, 53, -80, 71, 36, -14, -1, -3, 11, 30, -17, 20, 23, 50, -9, 4, 6, 11, -98, 26, 36, 13, -36, -13, 21, 43, 18, 6, 50, -21, -19, 6, -68, 50, 67, -128, -5, -20, -45, 9, -4, -21, 121, 35, -21, -19, 50, -35, 34, -4, -59, -103, -125, 30, -25, -7, 15, -86, 88, 123, -55, -13, 35, -11, 26, 78, -40, -6, -63, 13, -87, 14, 9, -80, 111, 115, -14, 5, 73, 13, 65, 36, -19, 56, -6, 13, -17, 2, 9, -111, 48, 82, -7, 81, 78, 18, 17, 30, 1, 25, 5, 19, -44, -14, 30, -115, -41, 89, 32, 21, 60, -14, 10, -4, -85, 4, 26, 37, 30, 5, 10, 15, 50, 30, 73, -21, 55, -11, -35, 41, -128, 65, 27, 11, 65, 3, 20, 102, 50, 43, 82, 23, -26, -1, -80, 61, -128, 120, -25, 1, 1, -25, 50, 43, -20, 4, 80, 106, -26, -2, -27, 19, -9, 7, -10, 10, -43, 9, 4, 14, 127, 63, -23, -39, 26, 1, 20, 6, -56, -11, 17, 24, 71, 6, 53, 9, 127, 4, -41, -20, 45, -13, 34, -1, -82, -50, 53, 56, 4, 5, 32, -2, 127, 3, -56, 2, 59, -15, 43, 40, -63, -40, 20, 34, -32, 13, 4, -15, 68, -30, -39, -1, 63, -2, 21, 13, -17, 6, -1, 27, -26, 24, 30, -30, 50, -20, 55, -5, 67, -10, 11, 32, 19, -36, 35, 2, 13, 24, 11, 3, 17, -17, 127, -96, 81, 3, -84, 15, -21, -70, 59, -3, 59, -45, 30, 40, 40, 6, 127, -48, 25, 5, -120, 70, -106, 48, 50, 10, -1, -6, 13, 71, 43, 5, 91, -2, -88, -10, -121, 60, -68, 127, -30, 19, 18, 39, -2, 27, 30, 43, 2, 5, 30, 13, 19, 26, -61, 15, -128, 34, -11, 9, 13, 32, 81, 35, -1, 41, 14, -4, 20, 53, -43, 11, -128, 56, -128, 35, 26, 5, -18, 35, 13, 35, 18, -9, 11, 83, -3, -15, -89, 7, -128, 21, 6, -6, -75, 4, 37, 45, -26, -32, 61, 40, 4, -91, 34, 19, -101, 21, 23, -39, -40, -68, 59, -1, -17, 26, 18, 19, 69, -59, 64, 34, -14, 24, 25, -55, 20, -94, 55, -83, 10, 6, -71, 25, 64, -104, 115, 48, 94, -20, 24, -30, 40, -109, 41, -41, 10, -1, -81, 61, -25, -85, 114, 36, -4, -37, 13, 24, 20, -43, 3, -96, -88, 23, -14, -1, -74, -64, -9, -3, 65, -25, -18, 13, -44, 14, 21, 35, 27, -4, 13, 24, -81, -2, -128, 27, -21, 13, -11, 14, -27, 4, 21, 65, 41, 17, 121, 50, -40, 2, -128, 17, -100, 21, -27, 6, -21, 44, 25, 80, 44, 39, 127, 67, -84, 25, -106, 43, -92, -25, 18, -3, -43, -7, 64, 82, -6, 55, 122, 61, 14, -18, 78, 30, -83, -30, 44, -123, -86, -56, 40, 40, -13, -17, 40, -41, 35, -98, 125, 24, -27, 1, 1, -120, -10, -128, 48, 3, -39, -23, -13, -6, 85, -109, 127, 7, 67, -13, 21, -128, -35, -59, 15, -48, -53, -11, 88, 37, 14, -128, 113, 23, 82, -5, 13, 114, 10, -102, 15, -86, -113, -6, 127, 1, -32, -115, 34, 4, 114, 49, 12, -58, -8, 14, -12, -5, -2, 8, -16, 1, 44, 26, -58, 18, -53, 40, 25, -78, 24, 56, 4, -60, -7, -2, -11, -7, -5, -2, -86, 5, -23, 40, 16, -84, -7, 34, -5, -58, 18, 18, -2, 30, -125, 6, -5, 7, 9, 50, 15, -87, -4, 50, -42, -58, 11, 23, 12, 36, -97, 16, -15, 26, -6, 60, 26, -24, 56, 57, -15, 7, 14, 18, 75, 32, -58, -11, -15, 60, 8, 39, 14, 3, 117, 20, -25, 3, 3, 1, 21, 32, -21, -8, -2, 53, -3, 32, 6, -4, 18, 8, -55, -1, 1, 20, 80, 24, -6, 6, -9, 21, -4, 52, -25, -11, 12, 30, -34, -15, 32, 16, -18, -1, 39, 2, 1, 47, 18, 40, 14, -98, -42, -2, -8, -3, -9, 7, -9, 9, 74, -46, -75, 25, -68, 19, 23, -100, -36, 14, -4, -21, 40, 15, -5, -21, 25, 4, -94, 28, -28, 44, 24, -109, -50, 26, -14, -19, 19, -19, -20, 18, -77, 15, -47, 49, -6, 30, -18, -55, 91, 69, -46, 7, 42, 19, 42, 15, -101, 20, -21, 34, 2, 26, 15, 2, 15, 44, -58, 53, 47, 5, 73, -1, -111, 60, -46, 55, -30, 39, 20, 26, 25, 28, -60, 16, 24, -9, 56, 7, -69, -5, -1, 44, -62, 52, 18, -40, 1, 39, -50, 57, 18, 11, 46, -4, -11, 5, -9, 44, -23, 53, 18, -60, -7, 46, -36, -3, 47, 3, 42, 12, 15, 11, 26, 16, -24, 57, -39, -101, -25, 19, -12, 24, -19, 50, -46, 19, 50, -16, 12, 26, -19, 32, -1, -119, -39, 57, -25, -9, 60, -25, -55, 26, 32, -26, 68, 25, -6, 32, 14, -68, -123, 60, -24, -21, 58, 5, -42, 49, -65, -19, -60, 60, 14, 44, 32, -30, -26, 53, -26, -14, 49, -3, -49, 32, -60, -11, -52, 65, -55, 49, 5, 72, -7, 74, -49, 14, 40, -2, -15, 21, -65, 42, -15, 44, -62, 57, 40, 116, 6, 60, -26, 39, 24, -1, 4, 7, -100, 60, 1, 68, -11, 39, 21, -40, -12, 46, -34, 60, 67, 4, -9, 6, -42, 127, 26, 53, -57, 20, 16, -26, 4, -6, -21, 49, 57, 12, -60, -4, 18, -44, 4, 30, -56, 32, 21, -12, -42, 11, -20, 3, 20, -21, 52, 21, 20, 56, -15, 44, -88, 28, 5, -70, -58, 16, -11, -14, 20, -8, 57, -9, 86, 49, 67, 49, -2, 9, 28, 73, -42, -1, -15, -39, 55, -32, 14, 12, 24, -1, -36, 26, -9, 28, 23, 84, 58, -1, -21, -9, 24, -6, 52, 72, -16, -36, -32, 32, -8, 34, 12, 73, 92, 18, -44, 9, 58, 3, 32, 58, 80, -3, -16, 49, 15, 21, 26, -5, 21, 78, -15, 20, 24, 4, 40, 23, -12, 18, -40, 36, -36, 5, 19, -11, -4, 28, 2, 39, 57, -7, 82, 7, -44, 55, -11, 56, -57, 15, 19, -28, 14, 28, -11, 58, 32, 11, -9, -7, -21, 127, 25, 58, -62, 18, 19, 40, -24, 32, -32, 65, -19, 46, 24, 70, -16, 101, -110, 40, -112, 34, 40, 15, -14, 39, -8, 65, 3, -5, 12, 34, 55, 127, -120, 30, -84, 16, 19, 47, -14, 16, -23, 56, 32, -16, -9, 25, 46, 24, -28, 42, -46, 18, 8, 55, -20, -23, 5, 6, 40, 1, 8, 56, -7, 24, 19, 55, -16, 30, 19, 60, 39, -60, -3, 40, 20, 8, 20, 55, -12, 25, 6, 30, 16, 30, 23, 9, -82, 11, -60, 34, 42, 2, 26, 34, 50, 14, -19, 26, 8, 25, 6, 3, -23, 26, -32, 36, 46, 19, 12, 8, -12, 34, -4, 34, -36, 11, 11, -65, 23, 6, -24, 65, 47, -3, 5, 32, 40, 105, 6, 47, -8, 49, 18, -4, -15, 53, -74, 32, 47, -39, 70, 58, -16, 68, -120, 20, -123, 28, 12, -67, 9, 73, -34, 84, 75, 3, 62, 40, -9, 52, -111, 32, -119, 39, 1, -90, -87, 68, -15, 26, 18, 5, -2, 14, 62, 30, -46, 32, -116, 24, -1, -1, 30, 58, 14, 32, 26, 18, -7, 40, 40, 50, 44, 42, -65, 30, 19, 23, 53, 30, 6, 50, 23, 7, 4, 7, -58, 127, 46, 56, 1, 36, 19, 57, -9, 20, -12, 75, 25, 2, 90, 47, -69, 77, 30, 70, 20, 25, 1, 84, -1, 21, 9, 42, 25, 15, 96, 34, -90, 49, 14, 49, -12, 28, 24, 52, 5, 19, -25, 14, -5, -12, 44, 39, 52, 91, -2, 25, -26, 39, 2, 12, 71, 44, -30, 26, 39, -8, 25, 30, -12, 68, -84, 28, -72, 28, 24, -34, 100, 62, -42, 71, 56, -14, 91, 24, -20, 18, -84, 32, -55, 30, 14, -44, 56, 47, -90, 52, 78, 2, 67, 25, -49, 20, 5, 42, -62, 21, 14, 7, 34, 53, -11, 15, 68, 15, 3, 14, 15, -4, 5, 34, 34, 60, 15, 42, 9, 57, 11, 50, 53, 7, 6, 16, -44, -1, 30, 34, 49, 36, 25, 92, -4, 18, 39, 94, 69, -16, 2, 11, -88, 103, 71, 24, 42, 2, -3, 116, 5, 5, 56, 97, 24, 7, -56, 11, -87, 127, 23, 14, -21, -1, 9, 127, 5, -5, -1, 92, -50, -2, -116, 21, 58, 127, -18, 19, -28, 36, -9, 24, 55, 55, -65, 25, 52, -39, 2, 14, -14, 67, -95, 32, -57, 11, 6, -47, 50, 69, -49, 58, 42, -9, -44, 20, -5, 84, -47, 40, -58, 26, 18, -47, 69, 50, -58, 39, 28, 3, -4, 23, 58, 18, 14, 42, -4, 19, 4, -62, 97, 11, -47, 28, 71, 16, 11, 49, -21, 26, 14, 32, 4, 26, 9, -25, -28, 46, 6, 19, 87, 9, 46, 19, -47, -18, 25, 42, 18, 49, 7, 44, 36, 58, 56, 47, 82, 9, -6, 12, -52, 7, 60, 46, 100, 20, 21, 100, -1, 14, 96, 94, 6, -8, 4, 6, -100, 21, 26, 32, 77, 12, 20, 106, 28, 2, -9, 127, -57, -2, 62, 1, -84, 117, -15, 56, -50, 49, 3, 36, 100, 25, -60, 12, 36, -16, 30, 9, -16, 75, -98, 28, -58, 36, 25, -16, 88, 44, -58, 42, 5, -9, 16, 62, -18, 94, -125, 34, -108, 32, 11, -68, 46, 67, -73, 40, 7, 6, 62, 60, 21, 75, -20, 16, -76, 55, 23, -90, 36, 60, -39, 19, 68, 11, 53, 52, 127, 77, -46, 36, -75, 16, 18, -25, -52, 20, 42, -16, 105, -4, -21, -6, 127, 30, 58, 52, -8, 24, 19, 116, 12, 49, 80, -2, 101, -3, -70, 23, -128, 95, 55, 56, 52, 15, 19, 127, -18, 75, 127, 19, 68, -15, -90, 11, -128, 88, -1, 62, 112, 6, 30, 58, 23, 53, 47, 87, -70, 9, -95, -6, -65, -47, -16, 55, 4, 19, 15, -4, 111, 78, -25, 20, 1, -1, 30, 8, -39, 14, -60, 15, -12, 6, 16, 3, 100, 58, -23, 36, -2, 6, 26, 58, -3, 44, -70, 23, -30, 23, -36, -5, 74, 24, -18, 32, -11, -11, 50, 16, -14, 105, -60, 44, -44, 24, 20, -70, 62, 9, -4, 68, 4, 7, 16, 25, 24, -60, -32, 36, -65, 44, 9, -128, 56, 1, 26, -8, 95, -6, -4, -4, 127, -106, 53, 62, -36, 24, 49, -90, -2, 18, 73, -74, 127, 6, -7, -1, 120, 24, 80, 34, 39, 15, 19, -9, 6, 28, 98, -58, 70, 3, -96, 69, -128, 121, 11, 50, 108, -8, 19, 55, 11, 53, 73, -32, -62, 11, -128, 30, -128, 75, -88, 52, 52, 21, -6, 9, 69, 44, -12, 19, 69, 8, 57, 62, -69, -19, -117, 42, -1, 40, -19, 18, 62, 58, -4, 40, 44, 8, 49, 32, -72, 23, -121, 42, -50, 52, 14, 19, -32, 74, -20, 39, 16, 5, 60, 53, -6, 58, -94, 16, -105, 42, 6, 7, -24, 16, -19, 58, -5, 2, 62, 58, 2, 1, -19, 28, -75, 26, 11, -70, -16, -65, -9, 60, -1, -2, 8, 12, 65, -36, 60, 36, -87, 9, 23, -88, 5, -42, -12, -69, 84, -11, 8, 11, 125, -128, 127, 26, 60, 32, 16, -56, 1, -21, 4, -123, 14, 4, -98, 73, 4, -97, 106, 60, 127, 21, 15, 46, 46, -1, -12, -128, -128, -8, -128, -6, -120, -46, -46, 47, 110, 36, 15, -5, 36, 65, -8, 20, 47, 8, 40, 19, -47, 40, -120, 21, -15, 15, 4, -18, 71, 44, -19, 52, 50, 19, 53, 28, -32, 20, -128, 19, -44, 44, 12, -1, 49, 60, -26, 55, 50, 36, 49, 36, -56, 28, -128, 34, -78, 40, 19, -1, -14, 49, -25, 72, -9, -2, 23, 60, -15, 58, -80, 39, -68, 1, 28, -84, -69, -32, -34, 67, -53, 28, 40, 34, 56, 1, 42, 58, -71, 34, 32, -128, -11, -128, -53, -6, -87, 23, -36, -20, 127, -78, 127, 42, 23, 21, 23, -128, 12, -106, -32, -82, -106, 16, -58, 8, 56, -128, 123, 40, 127, 4, 19, 40, 5, -108, -46, -128, -128, -34, 82, 32, -84, -128, -4, 21, 86, -42, -98, -6, -57, 2, 11, 3, -127, -99, 16, -54, -59, 11, 2, -16, 19, -89, -44, 1, 30, -54, 53, -77, -82, -27, -36, -89, -86, -28, -14, 33, -17, -92, -54, -11, -81, -77, -124, 66, -61, -115, -43, -8, -55, -2, -113, -115, 9, -78, -106, 20, 15, -48, 86, 2, -86, -89, 76, -128, -86, -77, -39, 16, 17, -68, -128, 37, 17, -46, 69, -45, -30, -33, -25, -87, 66, -1, -112, -97, 11, -69, -128, 8, 8, -59, -36, -43, -128, -23, 77, -100, -20, 11, -107, -106, -9, -128, -98, -3, -17, -99, -67, -14, -36, -11, -128, -1, -12, 77, -11, -16, -100, -128, -79, -69, -1, -73, -46, 30, -128, -17, -11, -9, -10, 3, -53, -80, 54, -54, -86, 51, 3, -32, -34, 2, -54, -111, -57, 6, -127, -79, 40, -112, -43, -128, -69, 20, -47, -128, -6, -44, -119, -123, -106, 6, -50, -7, 35, 6, 16, -77, -25, -15, 67, -97, 32, 47, -91, -36, 29, -24, -6, 7, -110, -60, 48, -40, -19, 14, -8, -10, 10, -9, -76, 50, -116, -18, -29, 23, 11, -101, -29, -120, -113, -32, -1, -9, 27, -8, -87, 69, -24, -46, 1, 30, -76, -91, -43, -86, -101, -76, -15, -20, -23, 36, -115, -29, -5, -22, -14, 55, -92, -128, 53, -73, -90, -73, -55, -1, -16, -7, -25, 27, -116, -97, -79, 24, -32, -42, 34, -128, -106, -128, -18, -128, 11, -15, -90, 71, 79, -114, -79, 76, -59, -128, 6, 82, -90, -1, -30, -122, 40, -109, -94, -123, -25, 25, -128, 36, -32, -71, -61, 4, -25, 42, -94, -106, -10, -91, -88, -109, 10, -24, -83, -42, 1, -60, 25, -16, -22, 25, 23, -114, 91, -61, -115, -33, -25, -57, -79, -73, 18, -42, -29, -1, -112, -12, 11, -14, -7, -86, -57, 18, -53, -86, -71, -55, -3, -109, -50, -44, -85, -4, -113, -73, 16, -54, -67, -10, 15, -10, -54, 9, -67, -94, 12, -97, -46, -44, -128, -9, -16, -50, -17, -59, 43, -124, -16, 2, -98, -59, 6, 15, -98, -128, -69, -47, 35, -48, -48, 54, 34, -96, -10, 89, -6, -43, -8, 34, 16, -100, -63, -43, -94, -79, -128, -12, 83, -106, -22, -12, -83, -63, -51, -40, -57, 77, -23, -114, 32, -113, -112, 33, 8, -128, 7, 29, 29, -64, -3, -43, 1, 68, -51, -88, -2, -29, -78, 7, 94, -42, -126, -64, -24, -39, -64, -87, -86, 51, 11, -36, 2, -20, 4, 89, 50, -128, -101, -16, -27, -119, 88, -34, -128, 15, -25, -55, -20, -122, -76, 48, -12, -100, -124, 20, -33, -25, 85, 6, -22, 34, -2, -9, 17, -87, -76, 67, -34, -44, -19, 82, -91, -34, -7, 50, -81, -30, 64, 4, 83, -67, -29, -54, 32, -73, 14, -73, -120, -120, -29, 22, -82, -128, 28, -63, 7, -77, -33, -3, -40, -110, 1, 25, -29, -82, 7, 3, -29, -12, -111, -71, -60, -15, -10, -57, -83, -55, -22, 42, -107, -81, 63, -66, -4, 17, 68, -128, 54, -100, -68, 1, -45, -116, 7, 34, -23, -112, -5, 78, -115, -14, 37, -78, -12, -128, -67, -63, 8, 25, -9, -14, -8, 5, 7, 2, -30, 28, -73, -48, -32, -66, -83, -22, -53, -128, -43, 37, -1, -5, 3, 16, -20, 87, -23, -124, 7, 37, -44, -10, -29, -98, -86, -71, -120, -69, 24, 68, -66, 82, -54, -66, -35, -19, -11, -30, -6, -103, -48, 15, -127, -10, -22, -2, -92, 18, -82, -128, 33, -37, -79, 3, -45, -128, -67, 2, -27, -89, -6, -35, -113, -71, 7, -66, -7, -60, -98, -50, -82, -89, 68, -18, -81, -119, -86, 29, -79, -83, -128, -71, -19, -100, -128, 2, 71, -110, -18, 29, -128, -93, -85, -34, 48, 51, 71, -25, -114, -124, -33, -48, -48, -128, -92, -40, 81, -88, 9, -110, -22, 15, -11, -36, 57, -91, -42, -93, -71, -37, -60, 6, -59, -128, -29, 68, -128, -42, -77, -33, 36, -93, -14, -66, 34, -11, 4, -20, 14, -29, -54, -25, -45, 37, 22, -53, 45, -1, -96, 39, -79, -126, -113, 55, -69, -48, -24, 25, -67, 29, -35, -96, -30, -47, -61, -9, 45, -90, -36, -47, -107, -53, -23, 8, -81, -53, -128, -22, 81, -88, -63, 1, -96, -94, -107, 24, -105, -68, 92, -3, -23, -54, -68, -128, 54, -64, -114, 9, -37, -119, -63, -18, -73, -128, 39, 68, -44, -43, -121, -48, -16, -81, -76, -6, -2, -93, 33, -14, -80, -121, -19, -7, 54, -9, 28, -53, 10, -22, -51, 61, -67, -20, -99, 33, 81, -85, 3, -25, -50, -3, -113, -85, 80, -15, -128, -69, -124, -61, -1, 16, -96, -115, -44, -29, -128, 16, -25, -7, 51, -47, -83, -30, -113, 6, -114, 2, -25, -96, 7, 88, -42, 5, -99, -115, 39, -78, -108, -46, 25, -71, -87, 5, 5, -55, 37, -1, -96, 1, -37, -92, 63, -8, -97, 29, -14, -71, -16, 95, -119, -3, -80, -17, -66, -43, -54, 1, 32, -25, -66, -22, -1, -98, -85, 27, -12, -73, 24, 3, -25, -86, -128, -96, 27, -17, -40, -10, -5, 14, 51, 6, -77, -17, 15, 42, -80, -25, -92, 8, -24, 19, -19, -35, 25, -64, 20, 25, -121, -97, -24, 7, -2, -63, -122, -29, 1, -128, -59, 127, -1, -81, -63, 126, 86, -120, -42, -10, -86, -30, -128, -33, -11, -111, -128, -8, -18, -54, -68, -20, -9, -76, 6, 24, -25, -39, -67, -110, 40, -82, -22, 20, -55, -59, -45, 28, 88, -128, 90, -36, -87, -33, -54, -22, -2, -100, -128, -15, 45, -115, -112, 20, -15, -101, -73, -50, -111, 10, -60, -124, 71, -69, -106, 1, -16, -128, -113, -23, -24, -128, 54, 82, -42, 71, -128, -47, -89, -36, -25, 46, 16, -60, -67, -19, -89, -43, -18, -57, -128, 3, -36, -128, 6, -94, -50, -53, 9, -110, -77, 17, -103, -30, -36, 7, -27, -46, -60, -101, 4, -80, -100, 44, -82, -77, -94, -28, -128, -82, -30, -16, 2, -16, -34, -88, 14, -67, -1, -20, -89, -91, -128, 1, -12, -44, 10, -53, 110, 55, -85, -105, -2, -109, -83, -1, -32, 5, -1, 60, 1, -98, -3, 29, -112, 30, -128, -25, -5, -61, 8, 25, -40, -16, -98, 37, -25, -99, -47, 44, -53, 59, -91, -47, 82, -85, -128, 28, -66, -81, -34, -86, 47, -33, -48, -3, -40, -66, -128, -9, -1, -47, -33, 16, -7, -106, 4, 18, 73, -105, 23, -25, -86, 2, -79, -51, -6, -39, -73, -28, 71, -66, -80, -36, -76, -128, 11, 20, -86, -54, -81, -96, 7, 3, -93, -63, 29, -100, -123, -1, -69, -18, 15, 54, -53, -51, -78, -1, 67, -81, -44, 14, -19, -32, -57, -15, -64, -101, -92, 28, 16, -11, -8, -106, 30, -40, 14, -8, -114, -19, -66, -79, -10, -81, 45, 57, -45, 40, -39, -6, -67, -83, -103, -67, -92, -107, -87, 110, 1, -34, -36, -44, -14, -25, -114, -97, 5, -103, -98, 71, -67, -47, -19, 47, 64, -111, -51, -42, -35, -34, -30, -23, 61, -64, -68, -55, -29, -78, -96, -5, -100, -59, -28, 73, -42, 14, -126, -127, 18, -71, -128, -9, -7, -51, -128, 20, -60, -128, 42, 19, -12, -10, -128, -85, -91, -46, -80, -50, 42, -123, -48, -91, -7, -116, 67, 2, -50, -94, -95, -126, 6, -15, -55, -42, -32, -51, -101, 4, -82, -124, -9, 43, -12, -69, -109, -53, 25, -91, -112, -37, 73, -128, -114, 97, -67, -71, -73, 46, 7, 30, 17, -10, -54, -55, -95, -4, -42, -80, -5, -128, -68, -85, 80, 1, -29, -37, -128, -81, 8, -88, -60, 47, -47, -97, -100, 4, -14, -39, 77, -20, -128, 18, -17, -78, -77, -53, -126, 1, -33, -111, -92, -2, 55, -2, 24, -46, -127, 3, -88, -128, 2, -60, -45, -7, 14, -86, -54, 20, 45, -34, 54, 6, -91, -89, -14, -15, -22, -97, -85, 39, -106, -121, -128, 23, -53, -57, -53, 82, -98, -67, -37, -61, 18, -68, -10, 76, -93, -53, -55, 120, -22, -63, -76, -28, -23, -92, -128, -105, -61, -83, 27, -59, 88, 3, -82, 115, -35, -107, 12, 71, -128, -95, -47, -87, 61, -128, -81, 92, 6, 3, -51, 9, -55, -76, -5, 18, 42, -110, 20, -109, -48, -29, 109, -28, -88, -64, -33, -126, 9, -48, 24, -63, 17, 9, -28, -120, 19, -60, 11, 28, -128, -92, -99, -12, -39, -111, 14, 2, 68, 7, -105, -79, -25, -48, -28, 4, 5, 10, -111, 35, 24, -4, -51, 28, 22, -67, -69, 6, 35, -101, 20, 46, -61, -92, -91, 8, -14, -81, 80, 3, -128, -48, 19, -57, -30, -79, 19, -42, -66, -128, -91, -42, -78, -39, -36, 53, -45, -27, -5, -42, 18, -79, 34, 2, -30, -128, -45, 2, 34, -12, 29, -44, -11, 7, -128, -29, 8, -128, -63, 30, -68, -11, -78, 122, -89, -97, -9, -60, -18, 32, -107, -73, -78, -110, -4, -42, 19, 12, -19, 50, -34, -98, -128 }; const int8_t fc_1_bias[ 48 ] = { -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1 }; const int8_t fc_2_kernel[ 48 * 21 ] = { -3, -127, -91, -60, -32, -2, 27, 73, -128, 5, -69, -7, -46, 79, 61, 22, -46, -43, -37, -30, -29, -61, -31, 42, 47, 71, 20, 42, -4, 1, -59, -9, -21, -80, -7, -55, 14, -70, 120, -20, -39, 6, 38, 28, -7, 89, 9, -31, 53, 14, -57, 1, -127, 3, -70, 10, -56, 78, -30, 71, 62, -55, -128, -27, -47, 63, 49, 20, -22, 33, -3, 12, -47, -85, -73, 21, -71, -4, -123, 127, 104, -35, -40, -76, -72, -24, 44, -39, -2, 64, 33, -8, -37, -51, 6, 54, 52, -47, -26, -111, 23, 97, 18, -50, -26, -128, 35, -126, -95, 116, 127, 90, -53, -82, -28, 97, -13, -11, 40, 82, 31, 38, 5, -23, -105, -15, 127, -95, 54, -116, -27, 7, -112, -28, 42, 5, -31, -42, 1, 52, 127, 4, 127, 101, 65, 26, -57, -58, -128, -10, -29, 25, -30, -40, -76, -33, 63, 121, -2, 58, 26, 102, 106, 21, -97, 88, -5, 69, 57, -116, 127, 57, 71, -81, 126, -88, -36, 53, 62, 9, -49, -26, 126, 55, -6, 11, -58, 32, 83, 36, -60, 113, -5, 27, 23, 8, -33, -14, -25, -56, 49, 30, -14, 58, -124, 49, -1, 23, 11, 67, -8, 7, -23, 33, -53, 21, 14, 4, -2, -25, -9, -17, -128, -14, 61, -17, -11, 10, -33, -5, -31, -47, -4, -2, -16, 10, -5, 10, -15, 4, 63, 127, -18, -28, 18, 33, 17, -50, -23, -11, -95, 47, -119, 2, 28, 62, 1, 51, 85, 83, -14, -64, -61, 27, -69, -78, 41, -28, 15, 22, -94, -94, -54, 40, -11, -27, 56, 5, -128, -105, 7, -49, -39, -47, 11, 90, 75, -16, 78, 127, 16, 18, -2, -3, -58, -21, -122, -108, -43, 6, -127, 18, 32, 27, 3, -62, -49, 63, 70, -16, -32, -15, -23, 28, -5, 51, 49, 46, -35, -8, -62, 34, -13, 17, 100, -24, 26, -30, 12, -1, 15, 11, 31, 8, 44, 1, 11, -128, -1, -19, -118, -55, -6, 107, 25, 3, -6, 20, 42, 63, -54, -29, 52, 112, -18, 29, 3, 38, 40, 7, -11, 4, -75, 4, 9, -13, -128, -107, 20, -19, -8, 3, -90, 23, 88, -123, 9, -46, -62, -13, 18, -118, -25, 10, 19, 18, -18, 40, 1, -2, -46, -23, -81, 27, -58, -49, -128, -56, 31, -74, 26, -32, 35, -51, -38, -42, -3, -21, 41, 47, 16, 3, -28, -8, 51, -31, 4, 16, -16, 73, 32, -20, 73, -20, -49, 23, 29, -32, -21, 58, 62, -42, 67, 45, -13, 95, -29, 46, 96, -34, -34, 125, -63, -63, -74, -28, 45, -72, -96, 107, 7, -128, -73, 61, 24, 23, 8, -104, -80, -48, 33, -10, -1, -9, -128, -21, -17, 19, -25, 21, 23, -33, 10, 37, 15, -55, -113, 54, 110, 48, -68, -128, -16, -121, -128, -24, 106, 25, -59, 119, 37, -40, 48, -6, 77, -70, -10, -50, 8, 50, 69, -41, -104, 92, -21, 111, 6, -128, -76, -128, -6, -92, -69, -27, 78, 80, 96, -27, 6, -33, -99, -37, 52, -112, 6, -24, -98, -99, -19, -17, -14, -25, -123, -13, 4, -35, 13, 31, -56, 29, 74, -38, -44, -28, -4, 30, 4, -23, 28, 9, 8, -6, 6, -65, -17, -19, -15, 12, -43, 32, -15, -19, 6, 18, -35, -15, -128, -36, -4, -19, -44, -7, 9, -14, -17, -24, 38, -128, 3, -11, -93, 15, -14, -17, 70, -54, 61, -106, -9, 37, 94, 19, 6, -114, -44, 8, -4, -22, 16, -84, -51, 70, 36, 50, -17, -5, 82, -37, 107, 13, -8, -74, 16, 31, -18, 127, -43, 64, 71, -24, -9, 21, -80, -1, -28, -38, -47, 43, -128, -5, 16, 10, 43, -18, -56, -58, 35, -16, -85, 20, -22, -74, 11, -1, -10, 23, -35, 37, -14, -60, -11, -61, -66, 37, 82, -1, -56, -22, -2, 15, 2, -36, 23, -45, 8, 19, -42, 16, -32, -14, -36, -20, -28, -9, 1, 35, 20, 98, -58, 48, 127, 53, -4, 36, -17, 50, -107, -90, -62, -37, -53, -57, -29, 125, 45, -82, -55, -104, -46, 50, 66, 32, -81, -17, -43, -29, 2, -69, -28, 11, -78, -98, -63, -41, 4, -26, 49, -128, -82, -14, 124, 28, 2, -117, 105, -30, -124, -20, 125, 33, -11, 9, -121, -121, -125, 21, -128, -128, -128, -34, -5, -128, -103, -128, -17, -128, 127, 6, 117, 5, -46, -128, 2, -16, -9, 3, 127, 3, -128, -6, -41, -107, -49, 109, 21, 6, -105, 33, 44, 49, -19, -20, 63, -77, -37, 8, -42, -10, -26, -125, -30, 35, 5, -56, -17, -92, 2, -7, 43, 34, -69, 2, -88, 40, -67, -35, 127, 9, -9, -87, 11, 42, -115, 82, 127, -61, -84, -23, 55, 17, -100, -13, -34, 71, -14, -18, 23, -118, 11, 48, -126, -53, 16, 44, 67, 51, -28, -33, 62, 11, -128, -9, 14, -28, 2, 32, 12, 5, -23, -49, 3, -9, 41, 12, -69, 21, -65, -104, -2, -30, -63, -26, -120, 70, 1, -16, 14, -1, -31, -66, 30, -79, -102, -31, 47, -52, -21, 27, 64, -19, -93, -128, -56, 48, -96, -42, 2, -74, 36, 67, 10, -105, 35, -59, -121, -60, -36, -124, 1, 50, 38, 29, -78, -47, 127, -105, -121, 42, 20, 13, 50, 4, -16, -57, -28, -96, 43, -80, -94, 21, -17, -25, 50, -34, -108, -80, 4, 65, 80, -29, 57, 84, -100, -128, 6, 5, -102, -33, -3, 5, -14, -47, 28, 99, -51, -7, 41, -128, 3, 43, 42, -1, 45, -92, 31, -78, 49, -47, 29, -70, -65, -85, -32, -14, -128, 29, -28, 70, -37, 16, 58, -16, 10, -79, -73, -74, -8, -116, -88, -128, -21, -32, -26, 17, -73, -68, 26, -128, -5, -25, -10, 25, 21, -18, 48, -120, -41, 39, -8, -50, -49, -62, -58, -14, -4, 58, -72, 9, 6, -17, -18, -52, 4, -62, -111, -65, -55, -12 }; const int8_t fc_2_bias[ 21 ] = { 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1 }; #endif
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/modules/ml/include/uai_odla_demo_data.h
C
apache-2.0
355,138
#ifndef HAAS_UAI_IMG_PROC_H #define HAAS_UAI_IMG_PROC_H #include "stdio.h" #include "uai_odla.h" #include "uai_load.h" #include "uai_quant.h" #include "uai_image.h" #include "aos/kernel.h" #define RGB565_TO_R(pixel) ((pixel & 0x1f) << 3) #define RGB565_TO_G(pixel) ((pixel & 0x7e0) >> 3) #define RGB565_TO_B(pixel) ((pixel & 0xf800) >> 8) void uai_get_split_img_data(uint8_t *ori_img_data, uint32_t ori_img_width, uint32_t ori_img_height, uint8_t *img_data, int img_width, int img_height, int start_x, int start_y) { uint8_t *temp_data; uai_img_data_t ori_img; ori_img.rows = ori_img_height; ori_img.colums = ori_img_width; ori_img.format = UAI_RGB565; ori_img.data = ori_img_data; uai_img_data_t new_img; new_img.rows = img_height; new_img.colums = img_width; new_img.format = UAI_RGB565; new_img.data = img_data; uai_image_split(&ori_img, &new_img, start_x, start_y); } void uai_get_resize_img(uint8_t *img_data, int img_width, int img_height, uint8_t *resized_img, int resize_width, int resize_height) { uai_img_data_t new_img; new_img.rows = img_height; new_img.colums = img_width; new_img.format = UAI_GRAY; new_img.data = img_data; uai_img_data_t resize_img; resize_img.rows = resize_height; resize_img.colums = resize_width; resize_img.format = UAI_GRAY; resize_img.data = resized_img; uai_img_resize(&new_img, &resize_img, UAI_IMG_INTER_BILINEAR); } void uai_convert_img(uint8_t *ori_img_data, int img_width, int img_height, uint8_t *new_img_data) { uai_img_data_t old_img; old_img.rows = img_height; old_img.colums = img_width; old_img.format = UAI_RGB565; old_img.data = ori_img_data; uai_img_data_t new_img; new_img.rows = img_height; new_img.colums = img_width; new_img.format = UAI_RGB888; new_img.data = new_img_data; uai_image_convert_ram(&old_img, &new_img); } void uai_get_gray_img(uint8_t *ori_img_data, int img_width, int img_height, uint8_t *new_img_data) { uai_img_data_t old_img; old_img.rows = img_height; old_img.colums = img_width; old_img.format = UAI_RGB565; old_img.data = ori_img_data; uai_img_data_t new_img; new_img.rows = img_height; new_img.colums = img_width; new_img.format = UAI_GRAY; new_img.data = new_img_data; uai_image_gray(&old_img, &new_img); } #endif
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/modules/ml/include/uai_odla_imgproc.h
C
apache-2.0
2,294
//===- Sinian Compiler Generated File -------------------------------------===// #ifndef HAAS_UAI_INTERFACE_H #define HAAS_UAI_INTERFACE_H #include "stdio.h" #include "uai_odla.h" #include "uai_load.h" #include "uai_quant.h" #include "uai_odla_demo_data.h" #define DEC_IMG_WIDTH 32 #define DEC_IMG_HEIGHT 48 #define DEC_IMG_CHANNEL 1 static odla_computation Comp; static odla_session Sess; static void alios_b0_helper(void *arg) { odla_computation comp = (odla_computation)arg; odla_value input = odla_AddArgument(comp, "input", INT8, (odla_dims)&(const _odla_dims) {.size = 4, .dims = {1, DEC_IMG_HEIGHT, DEC_IMG_WIDTH, 1}}); odla_value conv_1_kernel_ = odla_AddConstant( comp, INT8, (odla_dims)&(const _odla_dims) {.size = 4, .dims = {5, 5, DEC_IMG_CHANNEL, 2 * DEC_IMG_CHANNEL}}, conv_1_kernel); odla_value conv_1_bias_ = odla_AddConstant(comp, INT8, (odla_dims)&(const _odla_dims) {.size = 1, .dims = {2}}, conv_1_bias); odla_value conv_2_kernel_ = odla_AddConstant( comp, INT8, (odla_dims)&(const _odla_dims) {.size = 4, .dims = {5, 5, 2 * DEC_IMG_CHANNEL, 8 * DEC_IMG_CHANNEL }}, conv_2_kernel); odla_value conv_2_bias_ = odla_AddConstant(comp, INT8, (odla_dims)&(const _odla_dims) {.size = 1, .dims = {8}}, conv_2_bias); odla_value conv_3_kernel_ = odla_AddConstant( comp, INT8, (odla_dims)&(const _odla_dims) {.size = 4, .dims = {5, 5, 8, 16}}, conv_3_kernel); odla_value conv_3_bias_ = odla_AddConstant(comp, INT8, (odla_dims)&(const _odla_dims) {.size = 1, .dims = {16}}, conv_3_bias); odla_value fc_1_kernel_ = odla_AddConstant( comp, INT8, (odla_dims)&(const _odla_dims) {.size = 2, .dims = {1536, 48}}, fc_1_kernel); odla_value fc_1_bias_ = odla_AddConstant(comp, INT8, (odla_dims)&(const _odla_dims) {.size = 1, .dims = {48}}, fc_1_bias); odla_value fc_2_kernel_ = odla_AddConstant(comp, INT8, (odla_dims)&(const _odla_dims) {.size = 2, .dims = {48, 21}}, fc_2_kernel); odla_value fc_2_bias_ = odla_AddConstant(comp, INT8, (odla_dims)&(const _odla_dims) {.size = 1, .dims = {21}}, fc_2_bias); /* layer 1 */ odla_value conv_1_convolution = odla_Convolution( comp, INT8, (odla_dims)&(const _odla_dims) {.size = 4, .dims = {1, DEC_IMG_HEIGHT, DEC_IMG_WIDTH, 1}}, CHANNELS_LAST, input, (odla_dims)&(const _odla_dims) {.size = 4, .dims = {5, 5, 1, 2}}, SIO, conv_1_kernel_, (const unsigned[]){1, 1}, (const unsigned[]){1, 1}, (const unsigned[]){2, 2}, (const unsigned[]){2, 2}, conv_1_bias_, (odla_dims)&(const _odla_dims) {.size = 1, .dims = {2}}, SIO, (odla_dims)&(const _odla_dims) {.size = 4, .dims = {1, DEC_IMG_HEIGHT, DEC_IMG_WIDTH, 2}}); odla_value activation_1_Relu = odla_Relu( comp, INT8, (odla_dims)&(const _odla_dims) {.size = 4, .dims = {1, DEC_IMG_HEIGHT, DEC_IMG_WIDTH, 2}}, conv_1_convolution); odla_value max_pooling2d_1_MaxPool = odla_MaxPooling( comp, INT8, (odla_dims)&(const _odla_dims) {.size = 4, .dims = {1, DEC_IMG_HEIGHT, DEC_IMG_WIDTH, 2}}, CHANNELS_LAST, activation_1_Relu, (const unsigned[]){2, 2}, (const unsigned[]){2, 2}, (const unsigned[]){0, 0}, (const unsigned[]){0, 0}, (odla_dims)&(const _odla_dims) {.size = 4, .dims = {1, 24, 16, 2}}); /* layer 2 */ odla_value conv_2_convolution = odla_Convolution( comp, INT8, (odla_dims)&(const _odla_dims) {.size = 4, .dims = {1, 24, 16, 2}}, CHANNELS_LAST, max_pooling2d_1_MaxPool, (odla_dims)&(const _odla_dims) {.size = 4, .dims = {5, 5, 2, 8}}, SIO, conv_2_kernel_, (const unsigned[]){1, 1}, (const unsigned[]){1, 1}, (const unsigned[]){2, 2}, (const unsigned[]){2, 2}, conv_2_bias_, (odla_dims)&(const _odla_dims) {.size = 1, .dims = {8}}, SIO, (odla_dims)&(const _odla_dims) {.size = 4, .dims = {1, 24, 16, 8}}); odla_value activation_2_Relu = odla_Relu( comp, INT8, (odla_dims)&(const _odla_dims) {.size = 4, .dims = {1, 24, 16, 8}}, conv_2_convolution); odla_value max_pooling2d_2_MaxPool = odla_MaxPooling( comp, INT8, (odla_dims)&(const _odla_dims) {.size = 4, .dims = {1, 24, 16, 8}}, CHANNELS_LAST, activation_2_Relu, (const unsigned[]){2, 2}, (const unsigned[]){2, 2}, (const unsigned[]){0, 0}, (const unsigned[]){0, 0}, (odla_dims)&(const _odla_dims) {.size = 4, .dims = {1, 12, 8, 8}}); /* layer 3 */ odla_value conv_3_convolution = odla_Convolution( comp, INT8, (odla_dims)&(const _odla_dims) {.size = 4, .dims = {1, 12, 8, 8}}, CHANNELS_LAST, max_pooling2d_2_MaxPool, (odla_dims)&(const _odla_dims) {.size = 4, .dims = {5, 5, 8, 16}}, SIO, conv_3_kernel_, (const unsigned[]){1, 1}, (const unsigned[]){1, 1}, (const unsigned[]){2, 2}, (const unsigned[]){2, 2}, conv_3_bias_, (odla_dims)&(const _odla_dims) {.size = 1, .dims = {16}}, SIO, (odla_dims)&(const _odla_dims) {.size = 4, .dims = {1, 12, 8, 16}}); odla_value activation_3_Relu = odla_Relu( comp, INT8, (odla_dims)&(const _odla_dims) {.size = 4, .dims = {1, 12, 8, 16}}, conv_3_convolution); odla_value flatten_1_Reshape = odla_Reshape(comp, INT8, (odla_dims)&(const _odla_dims) {.size = 4, .dims = {1, 12, 8, 16}}, activation_3_Relu, (odla_dims)&(const _odla_dims) {.size = 2, .dims = {1, 1536}}); /* layer 4 */ odla_value fc_1_MatMul = odla_Gemm(comp, INT8, (odla_dims)&(const _odla_dims) {.size = 2, .dims = {1, 1536}}, flatten_1_Reshape, false, (odla_dims)&(const _odla_dims) {.size = 2, .dims = {1536, 48}}, fc_1_kernel_, false, fc_1_bias_, (odla_dims)&(const _odla_dims) {.size = 1, .dims = {48}}, SIO, (odla_dims)&(const _odla_dims) {.size = 2, .dims = {1, 48}}); odla_value activation_4_Relu = odla_Relu(comp, INT8, (odla_dims)&(const _odla_dims) {.size = 2, .dims = {1, 48}}, fc_1_MatMul); /* layer 5 */ odla_value fc_2_MatMul = odla_Gemm(comp, INT8, (odla_dims)&(const _odla_dims) {.size = 2, .dims = {1, 48}}, activation_4_Relu, false, (odla_dims)&(const _odla_dims) {.size = 2, .dims = {48, 21}}, fc_2_kernel_, false, fc_2_bias_, (odla_dims)&(const _odla_dims) {.size = 1, .dims = {21}}, SIO, (odla_dims)&(const _odla_dims) {.size = 2, .dims = {1, 21}}); odla_value output_Softmax = odla_Softmax(comp, INT8, (odla_dims)&(const _odla_dims) {.size = 2, .dims = {1, 21}}, fc_2_MatMul); odla_SetOutput(comp, "output_Softmax", output_Softmax); return; } void alios_b0(const int8_t* input, int8_t* out_output_Softmax) { if (Comp == NULL) { Comp = odla_CreateComputation(alios_b0_helper); } if (Sess == NULL) { Sess = odla_CreateSession(Comp); } odla_BindArgument(Sess, "input", INT8, (odla_dims)&(const _odla_dims) {.size = 4, .dims={1, DEC_IMG_HEIGHT, DEC_IMG_WIDTH, DEC_IMG_CHANNEL}}, input); odla_BindOutput(Sess, "output_Softmax", INT8, (odla_dims)&(const _odla_dims) {.size = 2, .dims={1, 21}}, out_output_Softmax); odla_Execute(Sess); } #endif
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/modules/ml/include/uai_odla_inference.h
C
apache-2.0
7,234
#ifndef HAAS_UAI_SCALE_DATA_H #define HAAS_UAI_SCALE_DATA_H #include "stdint.h" __attribute__ ((aligned (4))) const uint8_t uai_scale_data[] = { 0x1a, 0x1a, 0xa1, 0xa1, 0x05, 0x00, 0x14, 0x00, 0x17, 0xbe, 0xf3, 0x07, 0x0f, 0x0e, 0x0e, 0x10, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x08, 0x00, 0x10, 0x00, 0x30, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x08, 0x00, 0x10, 0x00, 0x30, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, 0xa9, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x00, 0xbf, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc1, 0x00, 0x00, 0x00, 0xc2, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, 0x0f, 0xec, 0x7a, 0x69, 0x48, 0x33, 0x44, 0x53, 0xd6, 0x29, 0xeb, 0x2d, 0xd0, 0x39, 0x8b, 0x1f, 0xdf, 0x1e, 0xff, 0x1e, 0x30, 0x20, 0xa1, 0x40, 0x84, 0x54, 0x3a, 0x3e, 0x80, 0x00, 0x2e, 0x15, 0xca, 0x59, 0x04, 0x27, 0xe7, 0x10, 0x44, 0x1f, 0xf2, 0xdb, 0xdb, 0x2f, 0xb4, 0x48, 0xbb, 0x28, 0x8e, 0xa9, 0xac, 0x0e, 0x64, 0x10, 0x61, 0x0b, 0xd5, 0x21, 0x01, 0x11, 0xef, 0xb1, 0x31, 0x10, 0xd6, 0x5d, 0xe5, 0x0a, 0x31, 0xbf, 0x73, 0x12, 0x8a, 0x29, 0xb8, 0x54, 0x00, 0xed, 0x9d, 0x0c, 0x52, 0x76, 0xd9, 0x0d, 0x2e, 0xd1, 0x59, 0x0f, 0x60, 0x37, 0x36, 0x13, 0x1f, 0xea, 0x0b, 0x13, 0x0d, 0x04, 0xf9, 0x2e, 0x8b, 0x4d, 0x49, 0x0c, 0xf9, 0xa4, 0x66, 0x5c, 0xb5, 0x50, 0x73, 0x18, 0x88, 0x00, 0x98, 0x3c, 0xb5, 0xf4, 0x06, 0x59, 0x95, 0x50, 0xe7, 0x19, 0x81, 0x2b, 0x06, 0x57, 0x06, 0x64, 0x34, 0x58, 0xdd, 0x66, 0x47, 0x21, 0xd5, 0x1a, 0xa7, 0x16, 0x5e, 0x95, 0x18, 0x18, 0x23, 0x1e, 0xe9, 0x53, 0x97, 0x17, 0xe9, 0x17, 0x1a, 0x17, 0xca, 0x13, 0x35, 0x14, 0x7d, 0x5c, 0x19, 0xce, 0xb0, 0x13, 0x5c, 0x72, 0x22, 0x57, 0x88, 0x45, 0x79, 0x62, 0x66, 0x21, 0xdc, 0x15, 0xc2, 0x45, 0x72, 0x57, 0xd6, 0x3b, 0x83, 0x63, 0x0c, 0x6d, 0x64, 0x5f, 0x82, 0x5d, 0x6f, 0x56, 0xf7, 0xe6, 0x0d, 0x56, 0xf8, 0x6c, 0x84, 0x57, 0x03, 0xb7, 0x7b, 0x54, 0xf4, 0xe4, 0xbd, 0x18, 0x0d, 0xb1, 0xef, 0x54, 0x6a, 0x4d, 0xd7, 0x59, 0x1d, 0xb0, 0x3d, 0x59, 0x02, 0x08, 0x09, 0x58, 0x26, 0x99, 0x8e, 0x16, 0x98, 0xb3, 0x14, 0x18, 0xea, 0x72, 0x83, 0x26, 0x06, 0xa2, 0x9c, 0x58, 0x69, 0x00, 0x6a, 0x55, 0x69, 0x8b, 0x8c, 0x52, 0x49, 0xfc, 0xb5, 0x18, 0x4e, 0x90, 0x92, 0x59, 0x60, 0xea, 0xe4, 0x14, 0x5e, 0x11, 0x95, 0x25, 0xf9, 0x10, 0xe7, 0x5a, 0x54, 0xce, 0xe3, 0x5a, 0x54, 0x20, 0xf9, 0x55, 0x15, 0xe7, 0x08, 0x57, 0xe1, 0xb8, 0xbc, 0x1a, 0xec, 0xc9, 0x99, 0x1c, 0x18, 0x57, 0xab, 0x19, 0x6b, 0xe2, 0xbe, 0x5b, 0x02, 0x0a, 0xb2, 0x30, 0x56, 0x9b, 0xc1, 0x2d, 0xdd, 0xba, 0x1b, 0x45, 0x9f, 0x5c, 0xea, 0x47, 0x42, 0x7c, 0xa0, 0x21, 0xad, 0x64, 0x02, 0x3b, 0xab, 0x1e, 0xe0, 0x2e, 0x7c, 0x5c, 0xcc, 0x36, 0xd7, 0xcb, 0x4b, 0x2d, 0x4b, 0xbe, 0x05, 0x3c, 0xc9, 0x5a, 0x85, 0x45, 0xfa, 0xa2, 0x03, 0x1c, 0x39, 0xe0, 0x3f, 0x37, 0x0d, 0x53, 0x3b, 0x23, 0xdc, 0x06, 0xce, 0x38, 0xe9, 0x85, 0xf4, 0x4b, 0x34, 0xf1, 0xfe, 0x3f, 0x18, 0x66, 0x35, 0x28, 0xb4, 0x68, 0xec, 0x45, 0xd8, 0xde, 0x17, 0x37, 0x51, 0x40, 0xa9, 0x2e, 0x86, 0xea, 0x04, 0x00, 0x56, 0xa6, 0x01, 0x00, 0xd8, 0xb0, 0x04, 0x00, 0x9f, 0xcf, 0x01, 0x00, 0xaf, 0x0e, 0x01, 0x00, 0xb6, 0xfe, 0x03, 0x00, 0xbe, 0xf0, 0x04, 0x00, 0x85, 0x23, 0x02, 0x00, 0x85, 0xdd, 0x02, 0x00, 0xd6, 0x2d, 0x0f, 0x00, 0x7e, 0x84, 0x0b, 0x00, 0x95, 0x32, 0x04, 0x00, 0x2d, 0x61, 0x02, 0x00, 0x46, 0x42, 0x01, 0x00, 0x05, 0x12, 0x06, 0x00, 0x4b, 0x96, 0x01, 0x00, 0x89, 0x2d, 0x0b, 0x00, 0xc9, 0x59, 0x0b, 0x00, 0x68, 0xaa, 0x02, 0x00, 0x96, 0x9a, 0x07, 0x00, 0x64, 0xc3, 0x04, 0x00, 0x3b, 0x21, 0x05, 0x00, 0x8d, 0x55, 0x02, 0x00, 0x71, 0xf8, 0x01, 0x00, 0x6c, 0x43, 0x0a, 0x00, 0x4e, 0xc9, 0x00, 0x00, 0xb9, 0xa6, 0x10, 0x00, 0xe5, 0x53, 0x10, 0x00, 0x1b, 0x7b, 0x0a, 0x00, 0xba, 0xa6, 0x10, 0x00, 0x28, 0x73, 0x15, 0x00, 0xb9, 0xa6, 0x10, 0x00, 0xb9, 0xa6, 0x10, 0x00, 0xf6, 0x7e, 0x40, 0x00, 0x5c, 0x9a, 0x6d, 0x00, 0x92, 0xec, 0x04, 0x00, 0xb9, 0xa6, 0x10, 0x00, 0x3b, 0xdf, 0x08, 0x00, 0x71, 0x5c, 0x20, 0x00, 0x81, 0x7a, 0x24, 0x00, 0xee, 0x83, 0x0c, 0x00, 0xb9, 0xa6, 0x10, 0x00, 0xe3, 0x81, 0x13, 0x00, 0xa9, 0x36, 0x08, 0x00, 0x79, 0x20, 0x42, 0x00, 0xee, 0xa7, 0x27, 0x00, 0x3c, 0xfd, 0x11, 0x00, 0xc5, 0x2f, 0x29, 0x00, 0xb9, 0xa6, 0x10, 0x00, 0xba, 0xa6, 0x10, 0x00, 0x3d, 0xd2, 0x0b, 0x00, 0xd6, 0x37, 0x09, 0x00, 0xb9, 0xa6, 0x10, 0x00, 0xb9, 0xa6, 0x10, 0x00, 0xb9, 0xa6, 0x10, 0x00, 0xb9, 0xa6, 0x10, 0x00, 0x3b, 0xac, 0x30, 0x00, 0x1b, 0x61, 0x0e, 0x00, 0xe9, 0xb5, 0x11, 0x00, 0xc6, 0xaf, 0x64, 0x00, 0xb9, 0xa6, 0x10, 0x00, 0xb9, 0xa6, 0x10, 0x00, 0xbd, 0xb3, 0x3a, 0x00, 0xb9, 0xa6, 0x10, 0x00, 0xb2, 0x93, 0x07, 0x00, 0xa9, 0xf8, 0x0a, 0x00, 0xba, 0xa6, 0x10, 0x00, 0xbd, 0xa6, 0x10, 0x00, 0xb9, 0xa6, 0x10, 0x00, 0xb9, 0xa6, 0x10, 0x00, 0x69, 0x73, 0xc4, 0x01, 0x66, 0x08, 0x10, 0x00, 0x37, 0x0c, 0x64, 0x00, 0xba, 0xa6, 0x10, 0x00, 0xd6, 0xd9, 0x08, 0x01, 0x45, 0x84, 0x90, 0x00, 0xe6, 0xd0, 0xc3, 0x00, 0xf0, 0x36, 0x9c, 0x00, 0x29, 0xad, 0xc1, 0x00, 0x14, 0xef, 0x3a, 0x04, 0xd8, 0x21, 0xff, 0x01, 0x7d, 0x37, 0x63, 0x03, 0x16, 0xb1, 0x6e, 0x00, 0x60, 0xee, 0xb8, 0x00, 0xda, 0x6c, 0x07, 0x11, 0x23, 0x48, 0x67, 0x04, 0x2c, 0x7e, 0xbf, 0x00, 0x94, 0xa9, 0x97, 0x00, 0xb6, 0xc4, 0xb7, 0x02, 0x35, 0x9c, 0x84, 0x00, 0xdd, 0x59, 0x53, 0x04, 0x5f, 0xcb, 0xd8, 0x00, 0xec, 0x4b, 0xda, 0x0a, 0x75, 0x64, 0xb7, 0x01, 0xe9, 0x38, 0x48, 0x00, 0x37, 0xb0, 0x29, 0x00, 0x42, 0x97, 0x0a, 0x00, 0x6f, 0x0c, 0x05, 0x00, 0x3f, 0x0e, 0x03, 0x00, 0x83, 0x75, 0x26, 0x00,}; const uint32_t uai_scale_data_len = sizeof(uai_scale_data); #endif
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/modules/ml/include/uai_scale_data.h
C
apache-2.0
8,617
#include "base/modules/ml/include/HaasML.h" #include "ulog/ulog.h" #include "base/modules/core/include/HaasErrno.h" #include "base/modules/ml/include/HaasMLCloud.h" #include "base/modules/ml/include/HaasMLMnn.h" #define LOG_TAG "HAASML" extern "C" { IHaasML* IHaasMLInstance(MLEngineType_t type) { LOGD(LOG_TAG, "entern type = %d;\n", type); IHaasML* mIHaasML = NULL; switch (type) { case ML_ENGINE_MNN: LOGD(LOG_TAG, "HaasMLMnn type = %d;\n", type); mIHaasML = new HaasMLMnn(); break; case ML_ENGINE_CLOUD: LOGD(LOG_TAG, "HaasMLCloud type = %d;\n", type); mIHaasML = new HaasMLCloud(); break; case ML_ENGINE_ODLA: LOGD(LOG_TAG, "HaasMLOlda type = %d;\n", type); //mIHaasML = new HaasMLOlda(); mIHaasML = NULL; break; default: LOGD(LOG_TAG, "illegal type = %d;\n", type); mIHaasML = NULL; } LOGD(LOG_TAG, "out type = %d;\n", type); return mIHaasML; } }
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/modules/ml/src/HaasML.cpp
C++
apache-2.0
1,164
#include "base/modules/ml/include/HaasMLCloud.h" #include <string> #include "base/modules/core/include/HaasErrno.h" #include "ulog/ulog.h" using namespace std; #define LOG_TAG "HAAS_ML_CLOUD" static ucloud_ai_result_t g_result[16]; static int g_index = 0; HaasMLCloud::HaasMLCloud() { LOGD(LOG_TAG, "entern\n"); } HaasMLCloud::~HaasMLCloud() { LOGD(LOG_TAG, "entern\n"); } int HaasMLCloud::Config(char *key, char *secret, char *endpoint, char *bucket) { LOGD(LOG_TAG, "entern\n"); LOGD(LOG_TAG, "key = %s;\n", key); LOGD(LOG_TAG, "secret = %s;\n", secret); LOGD(LOG_TAG, "endpoint = %s;\n", endpoint); LOGD(LOG_TAG, "bucket = %s;\n", bucket); ucloud_ai_set_key_secret(key, secret); ucloud_ai_set_oss_endpoint(endpoint); ucloud_ai_set_oss_bucket(bucket); return STATUS_OK; } int HaasMLCloud::SetInputData(const char *dataPath, const char *compareDataPath) { LOGD(LOG_TAG, "entern dataPath = %s, compareDataPath: %s;\n", dataPath, compareDataPath); mDataPath = const_cast<char *>(dataPath); if (compareDataPath) mFacePath = compareDataPath; return STATUS_OK; } int HaasMLCloud::LoadNet(const char *modePath) { LOGD(LOG_TAG, "entern modePath = %s;\n", modePath); mAiMode = const_cast<char *>(modePath); return STATUS_OK; } int HaasMLCloud::Predict() { LOGD(LOG_TAG, "entern mAiMode = %s;\n", mAiMode); int ret = -1; std::string mode(mAiMode); LOGD(LOG_TAG, "Train mode = %s;\n", mode.c_str()); g_index = 0; /*reset result*/ memset(g_result, 0, sizeof(ucloud_ai_result_t) * 16); ret = mode.compare("ObjectDet"); if (ret == 0) { LOGD(LOG_TAG, "Get ObjectDet Mode"); ret = PredictObjectDet(); goto end; } ret = mode.compare("FacebodyComparing"); if (ret == 0) { LOGD(LOG_TAG, "Get FacebodyComparing Mode"); ret = PredictFacebodyComparing(); goto end; } ret = mode.compare("AnimeStyle"); if (ret == 0) { LOGD(LOG_TAG, "Get AnimeStyle Mode"); ret = PredictAnimeStyle(); goto end; } ret = mode.compare("RecognizeExpression"); if (ret == 0) { LOGD(LOG_TAG, "Get RecognizeExpression Mode"); ret = PredictRecognizeExpression(); goto end; } ret = mode.compare("RecognizeCharacter"); if (ret == 0) { LOGD(LOG_TAG, "Get RecognizeCharacter Mode"); ret = PredictRecognizeCharacter(); goto end; } ret = mode.compare("DetectFruits"); if (ret == 0) { LOGD(LOG_TAG, "Get DetectFruits Mode"); for (int i = 0; i < g_index; i++) if (g_result[i].imagerecog.fruits.name != NULL) { free(g_result[i].imagerecog.fruits.name); g_result[i].imagerecog.fruits.name = NULL; } ret = PredictDetectFruits(); goto end; } ret = mode.compare("DetectPedestrian"); if (ret == 0) { LOGD(LOG_TAG, "Get DetectPedestrian Mode"); for (int i = 0; i < g_index; i++) if (g_result[i].facebody.pedestrian.type != NULL) { free(g_result[i].facebody.pedestrian.type); g_result[i].facebody.pedestrian.type = NULL; } ret = PredictDetectPedestrian(); goto end; } ret = mode.compare("RecognizeLicensePlate"); if (ret == 0) { LOGD(LOG_TAG, "Get RecognizeLicensePlate Mode"); for (int i = 0; i < g_index; i++) { if (g_result[i].ocr.licensePlate.plateNumber != NULL) { free(const_cast<char *>(g_result[i].ocr.licensePlate.plateNumber)); g_result[i].ocr.licensePlate.plateNumber = NULL; } if (g_result[i].ocr.licensePlate.plateType != NULL) { free(const_cast<char *>(g_result[i].ocr.licensePlate.plateType)); g_result[i].ocr.licensePlate.plateType = NULL; } } ret = PredictRecognizeLicensePlate(); goto end; } end: if (ret != STATUS_OK) LOGE(LOG_TAG, "AI Mode Par Is illegal\n"); return ret; } int HaasMLCloud::GetPredictResponses(char *outResult, int len) { LOGD(LOG_TAG, "entern\n"); if (g_index > 0) memcpy(outResult, &g_result[0], sizeof(ucloud_ai_result_t) * g_index); return g_index; } int HaasMLCloud::UnLoadNet() { LOGD(LOG_TAG, "entern\n"); int ret = 0; std::string mode(mAiMode); ret = mode.compare("DetectFruits"); if (ret == 0) { for (int i = 0; i < g_index; i++) if (g_result[i].imagerecog.fruits.name != NULL) { free(g_result[i].imagerecog.fruits.name); g_result[i].imagerecog.fruits.name = NULL; } goto end; } ret = mode.compare("DetectPedestrian"); if (ret == 0) { for (int i = 0; i < g_index; i++) if (g_result[i].facebody.pedestrian.type != NULL) { free(g_result[i].facebody.pedestrian.type); g_result[i].facebody.pedestrian.type = NULL; } goto end; } ret = mode.compare("RecognizeLicensePlate"); if (ret == 0) { for (int i = 0; i < g_index; i++) { if (g_result[i].ocr.licensePlate.plateNumber != NULL) { free(const_cast<char *>(g_result[i].ocr.licensePlate.plateNumber)); g_result[i].ocr.licensePlate.plateNumber = NULL; } if (g_result[i].ocr.licensePlate.plateType != NULL) { free(const_cast<char *>(g_result[i].ocr.licensePlate.plateType)); g_result[i].ocr.licensePlate.plateType = NULL; } } goto end; } end: return STATUS_OK; } int HaasMLCloud::PredictObjectDet() { LOGD(LOG_TAG, "entern\n"); ucloud_ai_objectdet_detect_object(mDataPath, ObjectDetectCallback); return STATUS_OK; } int HaasMLCloud::ObjectDetectCallback(void *result_in) { char *p_type = NULL; int x, y, w, h; char *type = NULL; float score; ucloud_ai_result_t *result = (ucloud_ai_result_t *)result_in; LOGD(LOG_TAG, "entern ObjectDetectCallback:\n"); if (!result) return -1; type = result->objectdet.object.type; score = result->objectdet.object.score; x = result->objectdet.object.box.x; y = result->objectdet.object.box.y; w = result->objectdet.object.box.w; h = result->objectdet.object.box.h; if (!type) { LOGE(LOG_TAG, "type is null\n"); return -1; } p_type = strdup(type); if (!p_type) { LOGE(LOG_TAG, "p_type strdup fail\n"); return -1; } LOGD(LOG_TAG, "Detect object result:\n"); LOGE(LOG_TAG, "type: %s, Score: %.1f, x: %d, y: %d, w: %d, h: %d\n", p_type, score, x, y, w, h); free(p_type); p_type = NULL; return 0; } int HaasMLCloud::PredictFacebodyComparing() { LOGD(LOG_TAG, "entern\n"); ucloud_ai_facebody_comparing_face(mDataPath, (char *)mFacePath.c_str(), FacebodyComparingCallback); return STATUS_OK; } int HaasMLCloud::FacebodyComparingCallback(void *result_in) { LOGD(LOG_TAG, "entern\n"); ucloud_ai_result_t *result = (ucloud_ai_result_t *)result_in; if (!result) return STATUS_ERROR; LOGD(LOG_TAG, "Facebody comparing result:\n"); if (g_index >= 16) return STATUS_ERROR; g_result[g_index].facebody.face.confidence = result->facebody.face.confidence; g_result[g_index].facebody.face.location.x = result->facebody.face.location.x; g_result[g_index].facebody.face.location.y = result->facebody.face.location.y; g_result[g_index].facebody.face.location.w = result->facebody.face.location.w; g_result[g_index].facebody.face.location.h = result->facebody.face.location.x; g_index++; return STATUS_OK; } int HaasMLCloud::AnimeStyleCallback(void *result_in) { LOGD(LOG_TAG, "entern\n"); char *url = NULL; ucloud_ai_result_t *result = (ucloud_ai_result_t *)result_in; if (!result) return -1; url = result->facebody.anime.url; LOGD(LOG_TAG, "Generate human anime style result:\n"); LOGE(LOG_TAG, "url: %s\n", url); return STATUS_OK; } int HaasMLCloud::PredictAnimeStyle() { LOGD(LOG_TAG, "entern\n"); ucloud_ai_facebody_generate_human_anime_style(mDataPath, AnimeStyleCallback); return STATUS_OK; } int HaasMLCloud::PredictRecognizeExpression() { LOGD(LOG_TAG, "entern\n"); ucloud_ai_facebody_recognize_expression(mDataPath, RecognizeExpressionCallback); return STATUS_OK; } int HaasMLCloud::RecognizeExpressionCallback(void *result_in) { LOGD(LOG_TAG, "entern\n"); char *expression, *p_expression; float face_probability; ucloud_ai_result_t *result = (ucloud_ai_result_t *)result_in; if (!result) return -1; expression = result->facebody.expression.expression; face_probability = result->facebody.expression.probability; if (!expression) return -1; p_expression = strdup(expression); if (!p_expression) { LOGE(LOG_TAG, "p_expression strdup fail\n"); return -1; } LOGE(LOG_TAG, "Recognize expression result:\n"); LOGE(LOG_TAG, "type: %s, probability: %.1f\n", p_expression, face_probability); free(p_expression); p_expression = NULL; return STATUS_OK; } int HaasMLCloud::DetectPedestrianCallback(void *result_in) { LOGD(LOG_TAG, "entern\n"); ucloud_ai_result_t *result = (ucloud_ai_result_t *)result_in; if (!result) return STATUS_ERROR; LOGD(LOG_TAG, "Detect Fruits result:\n"); if (g_index >= 16) return STATUS_ERROR; g_result[g_index].facebody.pedestrian.type = strdup(result->facebody.pedestrian.type); g_result[g_index].facebody.pedestrian.score = result->facebody.pedestrian.score; g_result[g_index].facebody.pedestrian.box.x = result->facebody.pedestrian.box.x; g_result[g_index].facebody.pedestrian.box.y = result->facebody.pedestrian.box.y; g_result[g_index].facebody.pedestrian.box.w = result->facebody.pedestrian.box.w; g_result[g_index].facebody.pedestrian.box.h = result->facebody.pedestrian.box.h; g_index++; return STATUS_OK; } int HaasMLCloud::PredictDetectPedestrian() { LOGD(LOG_TAG, "entern\n"); ucloud_ai_facebody_detect_pedestrian(mDataPath, DetectPedestrianCallback); return STATUS_OK; } int HaasMLCloud::DetectFruitsCallback(void *result_in) { LOGD(LOG_TAG, "entern\n"); ucloud_ai_result_t *result = (ucloud_ai_result_t *)result_in; if (!result) return STATUS_ERROR; LOGD(LOG_TAG, "Detect Fruits result:\n"); if (g_index >= 16) return STATUS_ERROR; g_result[g_index].imagerecog.fruits.name = strdup(result->imagerecog.fruits.name); g_result[g_index].imagerecog.fruits.score = result->imagerecog.fruits.score; g_result[g_index].imagerecog.fruits.box.x = result->imagerecog.fruits.box.x; g_result[g_index].imagerecog.fruits.box.y = result->imagerecog.fruits.box.y; g_result[g_index].imagerecog.fruits.box.w = result->imagerecog.fruits.box.w; g_result[g_index].imagerecog.fruits.box.h = result->imagerecog.fruits.box.h; g_index++; return STATUS_OK; } int HaasMLCloud::PredictDetectFruits() { LOGD(LOG_TAG, "entern\n"); ucloud_ai_imagerecog_detect_fruits(mDataPath, DetectFruitsCallback); return STATUS_OK; } int HaasMLCloud::RecognizeLicensePlateCallback(void *result_in) { LOGD(LOG_TAG, "entern\n"); ucloud_ai_result_t *result = (ucloud_ai_result_t *)result_in; if (!result) return STATUS_ERROR; LOGD(LOG_TAG, "Detect Fruits result:\n"); if (g_index >= 16) return STATUS_ERROR; g_result[g_index].ocr.licensePlate.plateNumber = strdup(result->ocr.licensePlate.plateNumber); g_result[g_index].ocr.licensePlate.plateType = strdup(result->ocr.licensePlate.plateType); g_result[g_index].ocr.licensePlate.confidence = result->ocr.licensePlate.confidence; g_result[g_index].ocr.licensePlate.plateTypeConfidence = result->ocr.licensePlate.plateTypeConfidence; g_result[g_index].ocr.licensePlate.roi.x = result->ocr.licensePlate.roi.x; g_result[g_index].ocr.licensePlate.roi.y = result->ocr.licensePlate.roi.y; g_result[g_index].ocr.licensePlate.roi.w = result->ocr.licensePlate.roi.w; g_result[g_index].ocr.licensePlate.roi.h = result->ocr.licensePlate.roi.h; g_index++; return STATUS_OK; } int HaasMLCloud::PredictRecognizeLicensePlate() { LOGD(LOG_TAG, "entern\n"); ucloud_ai_ocr_recognize_license_plate(mDataPath, RecognizeLicensePlateCallback); return STATUS_OK; } int HaasMLCloud::RecognizeCharacterCallback(void *result_in) { LOGD(LOG_TAG, "entern\n"); float probability; char *text = NULL; int left, top; int width, height; ucloud_ai_result_t *result = (ucloud_ai_result_t *)result_in; if (!result) return -1; LOGD(LOG_TAG, "Recognize character result:\n"); text = result->ocr.character.text; left = result->ocr.character.left; top = result->ocr.character.top; width = result->ocr.character.width; height = result->ocr.character.height; probability = result->ocr.character.probability; if (text) { LOGE(LOG_TAG, "text: %s\n", text); LOGE(LOG_TAG, "probability: %.1f\n", probability); LOGE(LOG_TAG, "text area: left: %d, top: %d, weight: %d, height: %d\n", top, left, width, height); } return STATUS_OK; } int HaasMLCloud::PredictRecognizeCharacter() { LOGD(LOG_TAG, "entern\n"); ucloud_ai_ocr_recognize_character(mDataPath, RecognizeCharacterCallback); return STATUS_OK; }
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/modules/ml/src/HaasMLCloud.cpp
C++
apache-2.0
13,665
#include "base/modules/ml/include/HaasMLMnn.h" #include "ulog/ulog.h" #include "base/modules/core/include/HaasErrno.h" #define LOG_TAG "HAAS_ML_MNN" HaasMLMnn::HaasMLMnn() { LOGD(LOG_TAG, "entern\n"); } HaasMLMnn::~HaasMLMnn() { LOGD(LOG_TAG, "entern\n"); } int HaasMLMnn::SetInputData(const char *dataPath, const char *compareDataPath) { LOGD(LOG_TAG, "entern\n"); return STATUS_OK; } int HaasMLMnn::LoadNet(const char* modePath) { LOGD(LOG_TAG, "entern\n"); return STATUS_OK; } int HaasMLMnn::Predict() { LOGD(LOG_TAG, "entern\n"); return STATUS_OK; } int HaasMLMnn::GetPredictResponses(char* outResult, int len) { LOGD(LOG_TAG, "entern\n"); return STATUS_OK; } int HaasMLMnn::UnLoadNet() { LOGD(LOG_TAG, "entern\n"); return STATUS_OK; }
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/modules/ml/src/HaasMLMnn.cpp
C++
apache-2.0
797
#if 0 #include "base/modules/ml/include/HaasMLOlda.h" #include "ulog/ulog.h" #include "base/modules/core/include/HaasErrno.h" #include "uai_quant.h" #include "uai_scale_data.h" #include "uai_img_data.h" #include "uai_odla_inference.h" #include "uai_odla_imgproc.h" #include "HaasImageCodecPng.h" #define LOG_TAG "HAAS_ML_OLDA" HaasMLOlda::HaasMLOlda() : input_scale(0), input_shift(0), norm_img_data(NULL) { LOGD(LOG_TAG, "entern\n"); norm_img_data = (uint8_t *)malloc(DEC_IMG_WIDTH * DEC_IMG_HEIGHT); memset(norm_img_data, 0, DEC_IMG_WIDTH * DEC_IMG_HEIGHT); memset(out_output_Softmax, 0, 21); } HaasMLOlda::~HaasMLOlda() { LOGD(LOG_TAG, "entern\n"); free(norm_img_data); norm_img_data = NULL; } int HaasMLOlda::SetInputData(const char *dataPath, const char *compareDataPath) { LOGD(LOG_TAG, "entern path = %s;\n", dataPath); HaasImageCodecPng * mHaasImageCodecPng = new HaasImageCodecPng(); ImageBuffer_t *image = mHaasImageCodecPng->ImgDecode(dataPath); if (image == NULL) { LOGD(LOG_TAG, "mHaasImageCodecBmp->ImgDecode failed\n"); } uint8_t *gray_img = NULL; LOGD(LOG_TAG, "bitmap pixels = %p;width = %d; height = %d;\n", image->address[0], image->width, image->height); gray_img = (uint8_t*)malloc(image->width * image->height); memset(gray_img, 0, image->width * image->height); uai_get_gray_img((uint8_t*)image->address[0], image->width, image->height, gray_img); uai_get_resize_img(gray_img, image->width, image->height, norm_img_data, DEC_IMG_WIDTH, DEC_IMG_HEIGHT); free(gray_img); free(image->address[0]); free(image); LOGD(LOG_TAG, "call delete mHaasImageCodecBmp\n"); delete mHaasImageCodecPng; return STATUS_OK; } int HaasMLOlda::LoadNet(const char* modePath) { LOGD(LOG_TAG, "entern\n"); char data_src[128]; uai_model_quant_scale_data_t *model_scale = NULL; memset(data_src, 0, 128); snprintf(data_src, 128, "mem:%u,size:%u", uai_scale_data, uai_scale_data_len); uai_load_model_scale_config(data_src); model_scale = uai_load_model_scale(); input_scale = model_scale->head.input_scale; input_shift = model_scale->head.input_shift; return STATUS_OK; } int HaasMLOlda::Predict() { LOGD(LOG_TAG, "entern\n"); uai_quant_normalize_uint8(norm_img_data, DEC_IMG_WIDTH * DEC_IMG_HEIGHT, input_scale, input_shift); alios_b0((const int8_t*)norm_img_data, out_output_Softmax); return STATUS_OK; } int HaasMLOlda::GetPredictResponses(char* outResult, int len) { LOGD(LOG_TAG, "entern\n"); if (outResult == NULL || len < 3) { LOGE(LOG_TAG, "par is illegal outResult = %p; len = %d;", outResult, len); return STATUS_ERROR; } memset(outResult, 0, len); uai_get_img_dec_result(out_output_Softmax, 21, outResult); LOGE(LOG_TAG, "AI RECOGNIZE number is: %s\n\n", outResult); LOGD(LOG_TAG, "score: \n"); for(int i = 0; i < 21; i++) { LOGD(LOG_TAG, "[%d]: %d\n", i, out_output_Softmax[i]); } return STATUS_OK; } int HaasMLOlda::UnLoadNet() { LOGD(LOG_TAG, "entern\n"); return STATUS_OK; } int HaasMLOlda::uai_get_img_dec_result(int8_t output_softmax[], int result_num, char *result) { int max_id = 0; int i = 0; for (int i = 0; i < result_num; i++) { if (output_softmax[i] > output_softmax[max_id]) { max_id = i; } } if (output_softmax[max_id] != 0) { if (max_id <= 9) { result[0] = 0x30 + max_id; result[1] = 0; } else { result[0] = 0x30 + max_id - 10; result[1] = '.'; result[2] = 0; } } return 0; } #endif
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/base/modules/ml/src/HaasMLOlda.cpp
C++
apache-2.0
3,621
#include <stdio.h> #include <string.h> #include <stdlib.h> #include "py/mperrno.h" #include "py/obj.h" #include "py/runtime.h" #include "py/builtin.h" #include "ulog/ulog.h" #include "base/modules/c/include/WrapperIHaasDataInput.h" #define LOG_TAG "DATAINPUT" extern const mp_obj_type_t minicv_datainput_type; // this is the actual C-structure for our new object typedef struct { // base represents some basic information, like type mp_obj_base_t Base; // a member created by us char *ModuleName; DataInputType_t mDataInputType; CameraNumber_t mCameraNum; char *mFileName; void *mInstance; } mp_datainput_obj_t; void datainput_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { LOGD(LOG_TAG, "entern %s;\n", __func__); mp_datainput_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_printf(print, "ModuleName(%s)", self->ModuleName); } STATIC mp_obj_t datainput_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s;\n", __func__); mp_datainput_obj_t* driver_obj = m_new_obj(mp_datainput_obj_t); if (!driver_obj) { mp_raise_OSError(MP_EINVAL); } driver_obj->Base.type = &minicv_datainput_type; driver_obj->ModuleName = "minicv-DataInput"; driver_obj->mDataInputType = DATA_INPUT_SOURCE_NONE; driver_obj->mCameraNum = DATA_INPUT_CAMERA_NUMBER_NONE; driver_obj->mFileName = NULL; driver_obj->mInstance = NULL; return MP_OBJ_FROM_PTR(driver_obj); } STATIC mp_obj_t obj_open(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 3) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_datainput_obj_t* driver_obj = (mp_datainput_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance != NULL) { LOGE(LOG_TAG, "Module has been opened, please clode first\n"); return mp_const_none; } driver_obj->mDataInputType = (DataInputType_t)mp_obj_get_int(args[1]); driver_obj->mFileName = (char *)mp_obj_str_get_str(args[2]); LOGD(LOG_TAG, "%s:mDataInputType = %d;\n", __func__, driver_obj->mDataInputType); LOGD(LOG_TAG, "%s:mFileName = %s;\n", __func__, driver_obj->mFileName); instance = DataInputCreateInstance(driver_obj->mDataInputType); driver_obj->mInstance = instance; if (instance == NULL) { LOGE(LOG_TAG, "DataInputCreateInstance failed\n"); return mp_const_none; } ret = DataInputOpen(instance, driver_obj->mFileName); if(ret) { LOGE(LOG_TAG, "\r\n=====datainput open failed===\r\n"); return mp_const_none; } return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(datainput_obj_open, 3, obj_open); STATIC mp_obj_t obj_openCamera(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 3) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_datainput_obj_t* driver_obj = (mp_datainput_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance != NULL) { LOGE(LOG_TAG, "Module has been opened, please clode first\n"); return mp_const_none; } driver_obj->mDataInputType = (DataInputType_t)mp_obj_get_int(args[1]); driver_obj->mCameraNum = (CameraNumber_t)mp_obj_get_int(args[2]); LOGD(LOG_TAG, "%s:mDataInputType = %d;\n", __func__, driver_obj->mDataInputType); LOGD(LOG_TAG, "%s:mCameraNum = %d;\n", __func__, driver_obj->mCameraNum); instance = DataInputCreateInstance(driver_obj->mDataInputType); driver_obj->mInstance = instance; if (instance == NULL) { LOGE(LOG_TAG, "DataInputCreateInstance failed\n"); return mp_const_none; } ret = DataInputOpen2(instance, driver_obj->mCameraNum); if(ret) { LOGE(LOG_TAG, "\r\n=====datainput opencamera failed===\r\n"); return mp_const_none; } LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(datainput_obj_openCamera, 3, obj_openCamera); STATIC mp_obj_t obj_close(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_datainput_obj_t* driver_obj = (mp_datainput_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has not been opened, not need close\n"); return mp_const_none; } DataInputClose(driver_obj->mInstance); driver_obj->mDataInputType = DATA_INPUT_SOURCE_NONE; driver_obj->mCameraNum = DATA_INPUT_CAMERA_NUMBER_NONE; driver_obj->mFileName = NULL; driver_obj->mInstance = NULL; LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(datainput_obj_close, 1, obj_close); STATIC mp_obj_t obj_checkDataReady(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); void* instance = NULL; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_datainput_obj_t* driver_obj = (mp_datainput_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has not been opened, please open first\n"); return mp_const_none; } int state = (int)DataInputCheckDataReady(driver_obj->mInstance); mp_obj_t ret = mp_obj_new_bool(state); LOGD(LOG_TAG, "%s:out state = %d;\n", __func__, state); return MP_ROM_INT(&ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(datainput_obj_checkDataReady, 1, obj_checkDataReady); STATIC mp_obj_t obj_requestData(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; ImageBuffer_t *image = NULL; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_datainput_obj_t* driver_obj = (mp_datainput_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has not been opened, please open first\n"); return mp_const_none; } ret = DataInputRequestData(driver_obj->mInstance, &image, 1000); if (ret != 0) { LOGE(LOG_TAG, "Request Data failed\n"); return mp_const_none; } LOGD(LOG_TAG, "%s:out image->address[0] = %p;image = %p;\n", __func__, image->address[0], image); return MP_OBJ_FROM_PTR(image); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(datainput_obj_requestData, 1, obj_requestData); STATIC mp_obj_t obj_releaseData(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 2) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_datainput_obj_t* driver_obj = (mp_datainput_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } ImageBuffer_t *image = (ImageBuffer_t *)MP_OBJ_TO_PTR(args[1]); if (image == NULL) { LOGE(LOG_TAG, "image is NULL\n"); return mp_const_none; } ret = DataInputReleaseData(driver_obj->mInstance, image); if (ret != 0) { LOGE(LOG_TAG, "Release Data failed\n"); return mp_const_none; } LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(datainput_obj_releaseData, 2, obj_releaseData); STATIC const mp_rom_map_elem_t datainput_locals_dict_table[] = { {MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_DataInput)}, {MP_OBJ_NEW_QSTR(MP_QSTR_DATA_INPUT_CAMERA_NUMBER_NONE), MP_ROM_INT(DATA_INPUT_CAMERA_NUMBER_NONE)}, {MP_OBJ_NEW_QSTR(MP_QSTR_DATA_INPUT_CAMERA_NUMBER_FRONT), MP_ROM_INT(DATA_INPUT_CAMERA_NUMBER_FRONT)}, {MP_OBJ_NEW_QSTR(MP_QSTR_DATA_INPUT_CAMERA_NUMBER_BACK), MP_ROM_INT(DATA_INPUT_CAMERA_NUMBER_BACK)}, {MP_OBJ_NEW_QSTR(MP_QSTR_DATA_INPUT_CAMERA_NUMBER_MAX), MP_ROM_INT(DATA_INPUT_CAMERA_NUMBER_MAX)}, {MP_OBJ_NEW_QSTR(MP_QSTR_DATA_INPUT_SOURCE_NONE), MP_ROM_INT(DATA_INPUT_SOURCE_NONE)}, {MP_OBJ_NEW_QSTR(MP_QSTR_DATA_INPUT_SOURCE_IMAGE_BMP), MP_ROM_INT(DATA_INPUT_SOURCE_IMAGE_BMP)}, {MP_OBJ_NEW_QSTR(MP_QSTR_DATA_INPUT_SOURCE_IMAGE_GIF), MP_ROM_INT(DATA_INPUT_SOURCE_IMAGE_GIF)}, {MP_OBJ_NEW_QSTR(MP_QSTR_DATA_INPUT_SOURCE_IMAGE_PNG), MP_ROM_INT(DATA_INPUT_SOURCE_IMAGE_PNG)}, {MP_OBJ_NEW_QSTR(MP_QSTR_DATA_INPUT_SOURCE_IMAGE_JPG), MP_ROM_INT(DATA_INPUT_SOURCE_IMAGE_JPG)}, {MP_OBJ_NEW_QSTR(MP_QSTR_DATA_INPUT_SOURCE_VIDEO_FILE), MP_ROM_INT(DATA_INPUT_SOURCE_VIDEO_FILE)}, {MP_OBJ_NEW_QSTR(MP_QSTR_DATA_INPUT_SOURCE_VIDEO_RTMP), MP_ROM_INT(DATA_INPUT_SOURCE_VIDEO_RTMP)}, {MP_OBJ_NEW_QSTR(MP_QSTR_DATA_INPUT_SOURCE_VIDEO_RTSP), MP_ROM_INT(DATA_INPUT_SOURCE_VIDEO_RTSP)}, {MP_OBJ_NEW_QSTR(MP_QSTR_DATA_INPUT_SOURCE_CAMERA_USB), MP_ROM_INT(DATA_INPUT_SOURCE_CAMERA_USB)}, {MP_OBJ_NEW_QSTR(MP_QSTR_DATA_INPUT_SOURCE_CAMERA_LOCAL), MP_ROM_INT(DATA_INPUT_SOURCE_CAMERA_LOCAL)}, {MP_OBJ_NEW_QSTR(MP_QSTR_DATA_INPUT_SOURCE_CAMERA_IP), MP_ROM_INT(DATA_INPUT_SOURCE_CAMERA_IP)}, {MP_OBJ_NEW_QSTR(MP_QSTR_DATA_INPUT_SOURCE_MAX), MP_ROM_INT(DATA_INPUT_SOURCE_MAX)}, {MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&datainput_obj_open)}, {MP_ROM_QSTR(MP_QSTR_openCamera), MP_ROM_PTR(&datainput_obj_openCamera)}, {MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&datainput_obj_close)}, {MP_ROM_QSTR(MP_QSTR_checkDataReady), MP_ROM_PTR(&datainput_obj_checkDataReady)}, {MP_ROM_QSTR(MP_QSTR_requestData), MP_ROM_PTR(&datainput_obj_requestData)}, {MP_ROM_QSTR(MP_QSTR_releaseData), MP_ROM_PTR(&datainput_obj_releaseData)}, }; STATIC MP_DEFINE_CONST_DICT(datainput_locals_dict, datainput_locals_dict_table); const mp_obj_type_t minicv_datainput_type = { .base = {&mp_type_type}, .name = MP_QSTR_DataInput, .print = datainput_obj_print, .make_new = datainput_obj_make_new, .locals_dict = (mp_obj_dict_t *)&datainput_locals_dict, };
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/datainput.c
C
apache-2.0
11,643
#include <stdio.h> #include <string.h> #include <stdlib.h> #include "py/mperrno.h" #include "py/obj.h" #include "py/runtime.h" #include "py/builtin.h" #include "ulog/ulog.h" #include "base/modules/c/include/WrapperIHaasImageCodec.h" #define LOG_TAG "IMAGE_CODEC" extern const mp_obj_type_t minicv_imagecodec_type; // this is the actual C-structure for our new object typedef struct { // base represents some basic information, like type mp_obj_base_t Base; // a member created by us char *ModuleName; CodecImageType_t mtype; void *mInstance; } mp_imagecodec_obj_t; void imagecodec_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { LOGD(LOG_TAG, "entern %s;\n", __func__); mp_imagecodec_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_printf(print, "ModuleName(%s)", self->ModuleName); } STATIC mp_obj_t imagecodec_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s;\n", __func__); mp_imagecodec_obj_t* driver_obj = m_new_obj(mp_imagecodec_obj_t); if (!driver_obj) { mp_raise_OSError(MP_EINVAL); } driver_obj->Base.type = &minicv_imagecodec_type; driver_obj->ModuleName = "minicv-ImageCodec"; driver_obj->mtype = CODEC_IMAGE_SOURCE_NONE; driver_obj->mInstance = NULL; return MP_OBJ_FROM_PTR(driver_obj); } STATIC mp_obj_t obj_open(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 2) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_imagecodec_obj_t* driver_obj = (mp_imagecodec_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance != NULL) { LOGE(LOG_TAG, "Module has been opened, please clode first\n"); return mp_const_none; } driver_obj->mtype = (CodecImageType_t)mp_obj_get_int(args[1]); LOGD(LOG_TAG, "%s:mtype = %d;\n", __func__, driver_obj->mtype); instance = ImageCodecCreateInstance(driver_obj->mtype); driver_obj->mInstance = instance; if (instance == NULL) { LOGE(LOG_TAG, "ImageCodecCreateInstance failed\n"); return mp_const_none; } LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imagecodec_obj_open, 2, obj_open); STATIC mp_obj_t obj_close(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_imagecodec_obj_t* driver_obj = (mp_imagecodec_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has not been opened, not need close\n"); return mp_const_none; } ImageCodecDestoryInstance(driver_obj->mInstance); driver_obj->mtype = CODEC_IMAGE_SOURCE_NONE; driver_obj->mInstance = NULL; LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imagecodec_obj_close, 1, obj_close); STATIC mp_obj_t obj_imgRead(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 2) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_imagecodec_obj_t* driver_obj = (mp_imagecodec_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } ImageBuffer_t *image = NULL; char *mFileName = (char *)mp_obj_str_get_str(args[1]); LOGD(LOG_TAG, "mFileName = %s;\n", mFileName); ret = ImageCodecImgRead(driver_obj->mInstance, &image, mFileName); if (ret != 0) { LOGE(LOG_TAG, "ImageCodecImgRead failed mFileName = %s;\n", mFileName); return mp_const_none; } LOGD(LOG_TAG, "%s:out image->address[0] = %p;image = %p;\n", __func__, image->address[0], image); return MP_OBJ_FROM_PTR(image); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imagecodec_obj_imgRead, 2, obj_imgRead); STATIC mp_obj_t obj_imgReadMulti(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 2) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_imagecodec_obj_t* driver_obj = (mp_imagecodec_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } ImageBuffer_t *image = NULL; char *mFileName = (char *)mp_obj_str_get_str(args[1]); LOGD(LOG_TAG, "mFileName = %s;\n", mFileName); ret = ImageCodecImgRead(driver_obj->mInstance, &image, mFileName); if (ret != 0) { LOGE(LOG_TAG, "ImageCodecImgRead failed mFileName = %s;\n", mFileName); return mp_const_none; } LOGD(LOG_TAG, "%s:out image->address[0] = %p;image = %p;\n", __func__, image->address[0], image); return MP_OBJ_FROM_PTR(image); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imagecodec_obj_imgReadMulti, 2, obj_imgReadMulti); STATIC mp_obj_t obj_imgWrite(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 3) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_imagecodec_obj_t* driver_obj = (mp_imagecodec_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } ImageBuffer_t *image = (ImageBuffer_t *)MP_OBJ_TO_PTR(args[1]); char *mFileName = (char *)mp_obj_str_get_str(args[2]); LOGD(LOG_TAG, "image = %p;\n", image); LOGD(LOG_TAG, "mFileName = %s;\n", mFileName); ret = ImageCodecImgWrite(driver_obj->mInstance, image, mFileName); if (ret) { LOGE(LOG_TAG, "%s:ImageCodecImgWrite failed\n", __func__); } LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imagecodec_obj_imgWrite, 3, obj_imgWrite); STATIC mp_obj_t obj_imgWriteMulti(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 3) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_imagecodec_obj_t* driver_obj = (mp_imagecodec_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } ImageBuffer_t **image = (ImageBuffer_t **)MP_OBJ_TO_PTR(args[1]); char *mFileName = (char *)mp_obj_str_get_str(args[2]); LOGD(LOG_TAG, "image = %p;\n", image); LOGD(LOG_TAG, "mFileName = %s;\n", mFileName); ret = ImageCodecImgWriteMulti(driver_obj->mInstance, image, mFileName); if (ret) { LOGE(LOG_TAG, "%s:ImageCodecImgWriteMulti failed\n", __func__); } LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imagecodec_obj_imgWriteMulti, 3, obj_imgWriteMulti); STATIC mp_obj_t obj_imgDecode(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 3) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_imagecodec_obj_t* driver_obj = (mp_imagecodec_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } void *addr = (void *)MP_OBJ_TO_PTR(args[1]); ImageBuffer_t **image = (ImageBuffer_t **)MP_OBJ_TO_PTR(args[2]); LOGD(LOG_TAG, "addr = %p;\n", addr); LOGD(LOG_TAG, "image = %p;\n", image); ret = ImageCodecImgDecode(driver_obj->mInstance, addr, image); if (ret) { LOGE(LOG_TAG, "%s:ImageCodecImgDecode failed\n", __func__); } LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imagecodec_obj_imgDecode, 3, obj_imgDecode); STATIC mp_obj_t obj_imgDecode2(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 2) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_imagecodec_obj_t* driver_obj = (mp_imagecodec_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } char *mFileName = (char *)mp_obj_str_get_str(args[1]); LOGD(LOG_TAG, "mFileName = %s;\n", mFileName); ImageBuffer_t *image = ImageCodecImgDecode2(driver_obj->mInstance, mFileName); if (image == NULL) { LOGE(LOG_TAG, "%s:ImageCodecImgDecode2 failed\n", __func__); } LOGD(LOG_TAG, "%s:out image = %p;\n", __func__, image); return MP_OBJ_FROM_PTR(image); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imagecodec_obj_imgDecode2, 2, obj_imgDecode2); STATIC mp_obj_t obj_imgEncode(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 3) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_imagecodec_obj_t* driver_obj = (mp_imagecodec_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } void *addr = (void *)MP_OBJ_TO_PTR(args[1]); ImageBuffer_t **image = (ImageBuffer_t **)MP_OBJ_TO_PTR(args[2]); LOGD(LOG_TAG, "addr = %p;\n", addr); LOGD(LOG_TAG, "image = %p;\n", image); ret = ImageCodecImgEncode(driver_obj->mInstance, addr, image); if (ret) { LOGE(LOG_TAG, "%s:ImageCodecImgEncode failed\n", __func__); } LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imagecodec_obj_imgEncode, 3, obj_imgEncode); STATIC mp_obj_t obj_haveImageReader(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 2) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_imagecodec_obj_t* driver_obj = (mp_imagecodec_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } char *mFileName = (char *)mp_obj_str_get_str(args[1]); LOGD(LOG_TAG, "mFileName = %s;\n", mFileName); ret = ImageCodechaveImageReader(driver_obj->mInstance, mFileName); if (ret) { LOGE(LOG_TAG, "%s:ImageCodechaveImageReader failed\n", __func__); } LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imagecodec_obj_haveImageReader, 2, obj_haveImageReader); STATIC mp_obj_t obj_haveImageWriter(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 2) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_imagecodec_obj_t* driver_obj = (mp_imagecodec_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } char *mFileName = (char *)mp_obj_str_get_str(args[1]); LOGD(LOG_TAG, "mFileName = %s;\n", mFileName); ret = ImageCodechaveImageWriter(driver_obj->mInstance, mFileName); if (ret) { LOGE(LOG_TAG, "%s:ImageCodechaveImageWriter failed\n", __func__); } LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imagecodec_obj_haveImageWriter, 2, obj_haveImageWriter); STATIC const mp_rom_map_elem_t imagecodec_locals_dict_table[] = { {MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ImageCodec)}, {MP_OBJ_NEW_QSTR(MP_QSTR_CODEC_IMAGE_SOURCE_NONE), MP_ROM_INT(CODEC_IMAGE_SOURCE_NONE)}, {MP_OBJ_NEW_QSTR(MP_QSTR_CODEC_IMAG_SOURCE_IMAGE_PNG), MP_ROM_INT(CODEC_IMAG_SOURCE_IMAGE_PNG)}, {MP_OBJ_NEW_QSTR(MP_QSTR_CODEC_IMAG_SOURCE_IMAGE_JPG), MP_ROM_INT(CODEC_IMAG_SOURCE_IMAGE_JPG)}, {MP_OBJ_NEW_QSTR(MP_QSTR_CODEC_IMAG_SOURCE_IMAGE_BMP), MP_ROM_INT(CODEC_IMAG_SOURCE_IMAGE_BMP)}, {MP_OBJ_NEW_QSTR(MP_QSTR_CODEC_IMAG_SOURCE_IMAGE_GIF), MP_ROM_INT(CODEC_IMAG_SOURCE_IMAGE_GIF)}, {MP_OBJ_NEW_QSTR(MP_QSTR_CODEC_IMAG_SOURCE_MAX), MP_ROM_INT(CODEC_IMAG_SOURCE_MAX)}, {MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&imagecodec_obj_open)}, {MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&imagecodec_obj_close)}, {MP_ROM_QSTR(MP_QSTR_imgRead), MP_ROM_PTR(&imagecodec_obj_imgRead)}, {MP_ROM_QSTR(MP_QSTR_imgReadMulti), MP_ROM_PTR(&imagecodec_obj_imgReadMulti)}, {MP_ROM_QSTR(MP_QSTR_imgWrite), MP_ROM_PTR(&imagecodec_obj_imgWrite)}, {MP_ROM_QSTR(MP_QSTR_imgWriteMulti), MP_ROM_PTR(&imagecodec_obj_imgWriteMulti)}, {MP_ROM_QSTR(MP_QSTR_imgDecode), MP_ROM_PTR(&imagecodec_obj_imgDecode)}, {MP_ROM_QSTR(MP_QSTR_imgDecode2), MP_ROM_PTR(&imagecodec_obj_imgDecode2)}, {MP_ROM_QSTR(MP_QSTR_imgEncode), MP_ROM_PTR(&imagecodec_obj_imgEncode)}, {MP_ROM_QSTR(MP_QSTR_haveImageReader), MP_ROM_PTR(&imagecodec_obj_haveImageReader)}, {MP_ROM_QSTR(MP_QSTR_haveImageWriter), MP_ROM_PTR(&imagecodec_obj_haveImageWriter)}, }; STATIC MP_DEFINE_CONST_DICT(imagecodec_locals_dict, imagecodec_locals_dict_table); const mp_obj_type_t minicv_imagecodec_type = { .base = {&mp_type_type}, .name = MP_QSTR_ImageCodec, .print = imagecodec_obj_print, .make_new = imagecodec_obj_make_new, .locals_dict = (mp_obj_dict_t *)&imagecodec_locals_dict, };
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/imagecodec.c
C
apache-2.0
16,863
#include <stdio.h> #include <string.h> #include <stdlib.h> #include "py/mperrno.h" #include "py/obj.h" #include "py/runtime.h" #include "py/builtin.h" #include "ulog/ulog.h" #include "base/modules/c/include/WrapperIHaasImageProc.h" #define LOG_TAG "IMAGE_PROC" extern const mp_obj_type_t minicv_imageproc_type; // this is the actual C-structure for our new object typedef struct { // base represents some basic information, like type mp_obj_base_t Base; // a member created by us char *ModuleName; ImageProcType_t mType; void *mInstance; } mp_imageproc_obj_t; void imageproc_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { LOGD(LOG_TAG, "entern %s;\n", __func__); mp_imageproc_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_printf(print, "ModuleName(%s)", self->ModuleName); } STATIC mp_obj_t imageproc_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s;\n", __func__); mp_imageproc_obj_t* driver_obj = m_new_obj(mp_imageproc_obj_t); if (!driver_obj) { mp_raise_OSError(MP_EINVAL); } driver_obj->Base.type = &minicv_imageproc_type; driver_obj->ModuleName = "minicv-ImageProc"; driver_obj->mType = IMAGE_PROC_NONE; driver_obj->mInstance = NULL; return MP_OBJ_FROM_PTR(driver_obj); } STATIC mp_obj_t obj_open(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 2) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_imageproc_obj_t* driver_obj = (mp_imageproc_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance != NULL) { LOGE(LOG_TAG, "Module has been opened, please clode first\n"); return mp_const_none; } driver_obj->mType = (ImageProcType_t)mp_obj_get_int(args[1]); LOGD(LOG_TAG, "%s:mType = %d;\n", __func__, driver_obj->mType); instance = ImageProcCreateInstance(driver_obj->mType); driver_obj->mInstance = instance; if (instance == NULL) { LOGE(LOG_TAG, "ImageProcCreateInstance failed\n"); return mp_const_none; } ret = ImageProcOpen(driver_obj->mInstance); LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imageproc_obj_open, 2, obj_open); STATIC mp_obj_t obj_close(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_imageproc_obj_t* driver_obj = (mp_imageproc_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has not been opened, not need close\n"); return mp_const_none; } ret = ImageProcClose(driver_obj->mInstance); ImageProcDestoryInstance(driver_obj->mInstance); driver_obj->mType = IMAGE_PROC_NONE; driver_obj->mInstance = NULL; LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imageproc_obj_close, 1, obj_close); STATIC mp_obj_t obj_cvtColor(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 4) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_imageproc_obj_t* driver_obj = (mp_imageproc_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } ImageBuffer_t* src = (ImageBuffer_t*)MP_OBJ_TO_PTR(args[1]); PixelFmt_t dst_format = (PixelFmt_t)mp_obj_get_int(args[2]); ImageBuffer_t* dst = (ImageBuffer_t*)MP_OBJ_TO_PTR(args[3]); LOGD(LOG_TAG, "src = %p;dst_format = %d; dst = %p;\n", src, dst_format, dst); ret = ImageProcCvtColor(driver_obj->mInstance, src, dst_format, &dst); LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imageproc_obj_cvtColor, 4, obj_cvtColor); STATIC mp_obj_t obj_resize(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 5) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_imageproc_obj_t* driver_obj = (mp_imageproc_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } ImageBuffer_t* src = (ImageBuffer_t*)MP_OBJ_TO_PTR(args[1]); uint32_t width = (uint32_t)mp_obj_get_int(args[2]); uint32_t height = (uint32_t)mp_obj_get_int(args[3]); ImageBuffer_t* dst = (ImageBuffer_t*)MP_OBJ_TO_PTR(args[4]); LOGD(LOG_TAG, "src = %p;width = %d; height = %d; dst = %p;\n", src, width, height, dst); ImageSize_t imgSize; imgSize.width = width; imgSize.height = height; ret = ImageProcResize(driver_obj->mInstance, src, imgSize, &dst); LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imageproc_obj_resize, 5, obj_resize); STATIC mp_obj_t obj_imgCopy(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 3) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_imageproc_obj_t* driver_obj = (mp_imageproc_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } ImageBuffer_t* src = (ImageBuffer_t*)MP_OBJ_TO_PTR(args[1]); ImageBuffer_t* dst = (ImageBuffer_t*)MP_OBJ_TO_PTR(args[2]); LOGD(LOG_TAG, "src = %p; dst = %p;\n", src, dst); ret = ImageProcImgCopy(driver_obj->mInstance, src, &dst); LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imageproc_obj_imgCopy, 3, obj_imgCopy); STATIC mp_obj_t obj_rectangle(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 6) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_imageproc_obj_t* driver_obj = (mp_imageproc_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } ImageBuffer_t* src = (ImageBuffer_t*)MP_OBJ_TO_PTR(args[1]); int32_t left = (int32_t)mp_obj_get_int(args[2]); int32_t top = (int32_t)mp_obj_get_int(args[3]); int32_t right = (int32_t)mp_obj_get_int(args[4]); int32_t bottom = (int32_t)mp_obj_get_int(args[5]); LOGD(LOG_TAG, "src = %p;left = %d; top = %d; right = %d;bottom = %d;\n", src, left, top, right, bottom); ret = ImageProcRectangle(driver_obj->mInstance, src, left, top, right, bottom); LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imageproc_obj_rectangle, 6, obj_rectangle); STATIC mp_obj_t obj_circle(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 5) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_imageproc_obj_t* driver_obj = (mp_imageproc_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } ImageBuffer_t* src = (ImageBuffer_t*)MP_OBJ_TO_PTR(args[1]); int32_t center_x = (int32_t)mp_obj_get_int(args[2]); int32_t center_y = (int32_t)mp_obj_get_int(args[3]); int32_t radius = (int32_t)mp_obj_get_int(args[4]); LOGD(LOG_TAG, "src = %p;center_x = %d; center_y = %d; radius = %d;\n", src, center_x, center_y, radius); ret = ImageProcCircle(driver_obj->mInstance, src, center_x, center_y, radius); LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imageproc_obj_circle, 5, obj_circle); STATIC mp_obj_t obj_drawMarker(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 5) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_imageproc_obj_t* driver_obj = (mp_imageproc_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } ImageBuffer_t* src = (ImageBuffer_t*)MP_OBJ_TO_PTR(args[1]); uint32_t x = (uint32_t)mp_obj_get_int(args[2]); uint32_t y = (uint32_t)mp_obj_get_int(args[3]); int32_t type = (int32_t)mp_obj_get_int(args[4]); LOGD(LOG_TAG, "src = %p;x = %d; y = %d; type = %d;\n", src, x, y, type); Point_t pt; pt.x = x; pt.y = y; ret = ImageProcDrawMarker(driver_obj->mInstance, src, &pt, type); LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imageproc_obj_drawMarker, 5, obj_drawMarker); STATIC mp_obj_t obj_fillPoly(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 5) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_imageproc_obj_t* driver_obj = (mp_imageproc_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } ImageBuffer_t* src = (ImageBuffer_t*)MP_OBJ_TO_PTR(args[1]); uint32_t x = (uint32_t)mp_obj_get_int(args[2]); uint32_t y = (uint32_t)mp_obj_get_int(args[3]); int32_t color = (int32_t)mp_obj_get_int(args[4]); LOGD(LOG_TAG, "src = %p;x = %d; y = %d; color = %d;\n", src, x, y, color); Point_t pt; pt.x = x; pt.y = y; Point_t *ptt = &pt; ret = ImageProcFillPoly(driver_obj->mInstance, src, &ptt, color); LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imageproc_obj_fillPoly, 5, obj_fillPoly); STATIC mp_obj_t obj_putText(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 5) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_imageproc_obj_t* driver_obj = (mp_imageproc_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } ImageBuffer_t* src = (ImageBuffer_t*)MP_OBJ_TO_PTR(args[1]); char* text = (char*)mp_obj_str_get_str(args[2]); int32_t left = (int32_t)mp_obj_get_int(args[3]); int32_t top = (int32_t)mp_obj_get_int(args[4]); LOGD(LOG_TAG, "src = %p;text = %s; left = %d; top = %d;\n", src, text, left, top); ret = ImageProcPutText(driver_obj->mInstance, src, text, left, top); LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imageproc_obj_putText, 5, obj_putText); STATIC mp_obj_t obj_dilateErode(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 5) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_imageproc_obj_t* driver_obj = (mp_imageproc_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } ImageBuffer_t* src = (ImageBuffer_t*)MP_OBJ_TO_PTR(args[1]); ImageBuffer_t* dst = (ImageBuffer_t*)MP_OBJ_TO_PTR(args[2]); int32_t iMode = (int32_t)mp_obj_get_int(args[3]); int32_t iThresh = (int32_t)mp_obj_get_int(args[4]); LOGD(LOG_TAG, "src = %p;dst = %p; iMode = %d; iThresh = %d;\n", src, dst, iMode, iThresh); ret = ImageProcDilateErode(driver_obj->mInstance, src, dst, iMode, iThresh); LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imageproc_obj_dilateErode, 5, obj_dilateErode); STATIC mp_obj_t obj_imageAdd(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 5) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_imageproc_obj_t* driver_obj = (mp_imageproc_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } ImageBuffer_t* src = (ImageBuffer_t*)MP_OBJ_TO_PTR(args[1]); ImageBuffer_t* added = (ImageBuffer_t*)MP_OBJ_TO_PTR(args[2]); ImageBuffer_t* dst = (ImageBuffer_t*)MP_OBJ_TO_PTR(args[3]); LOGD(LOG_TAG, "src = %p;added = %p; dst = %p;\n", src, added, dst); ImageProcImageAdd(driver_obj->mInstance, src, added, dst); LOGD(LOG_TAG, "%s:out \n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imageproc_obj_imageAdd, 4, obj_imageAdd); STATIC mp_obj_t obj_imageMinus(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 4) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_imageproc_obj_t* driver_obj = (mp_imageproc_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } ImageBuffer_t* src = (ImageBuffer_t*)MP_OBJ_TO_PTR(args[1]); ImageBuffer_t* minused = (ImageBuffer_t*)MP_OBJ_TO_PTR(args[2]); ImageBuffer_t* dst = (ImageBuffer_t*)MP_OBJ_TO_PTR(args[3]); LOGD(LOG_TAG, "src = %p;minused = %p; dst = %p;\n", src, minused, dst); ImageProcImageMinus(driver_obj->mInstance, src, minused, dst); LOGD(LOG_TAG, "%s:out \n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imageproc_obj_imageMinus, 4, obj_imageMinus); STATIC mp_obj_t obj_imageElementMultiply(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 4) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_imageproc_obj_t* driver_obj = (mp_imageproc_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } ImageBuffer_t* src = (ImageBuffer_t*)MP_OBJ_TO_PTR(args[1]); ImageBuffer_t* multiplied = (ImageBuffer_t*)MP_OBJ_TO_PTR(args[2]); ImageBuffer_t* dst = (ImageBuffer_t*)MP_OBJ_TO_PTR(args[3]); LOGD(LOG_TAG, "src = %p;multiplied = %p; dst = %p;\n", src, multiplied, dst); ImageProcImageElementMultiply(driver_obj->mInstance, src, multiplied, dst); LOGD(LOG_TAG, "%s:out \n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imageproc_obj_imageElementMultiply, 4, obj_imageElementMultiply); STATIC mp_obj_t obj_imageElementDivide(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 4) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_imageproc_obj_t* driver_obj = (mp_imageproc_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } ImageBuffer_t* src = (ImageBuffer_t*)MP_OBJ_TO_PTR(args[1]); ImageBuffer_t* divied = (ImageBuffer_t*)MP_OBJ_TO_PTR(args[2]); ImageBuffer_t* dst = (ImageBuffer_t*)MP_OBJ_TO_PTR(args[3]); LOGD(LOG_TAG, "src = %p;divied = %p; dst = %p;\n", src, divied, dst); ImageProcImageElementDivide(driver_obj->mInstance, src, divied, dst); LOGD(LOG_TAG, "%s:out \n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imageproc_obj_imageElementDivide, 4, obj_imageElementDivide); STATIC mp_obj_t obj_writeImageToFile(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 3) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_imageproc_obj_t* driver_obj = (mp_imageproc_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } ImageBuffer_t* src = (ImageBuffer_t*)MP_OBJ_TO_PTR(args[1]); char* file_name = (char*)mp_obj_str_get_str(args[2]); LOGD(LOG_TAG, "src = %p;file_name = %s;\n", src, file_name); ret = ImageProcWriteImageToFile(driver_obj->mInstance, src, file_name); LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imageproc_obj_writeImageToFile, 3, obj_writeImageToFile); STATIC const mp_rom_map_elem_t imageproc_locals_dict_table[] = { {MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ImageProc)}, {MP_OBJ_NEW_QSTR(MP_QSTR_IMAGE_PROC_NONE), MP_ROM_INT(IMAGE_PROC_NONE)}, {MP_OBJ_NEW_QSTR(MP_QSTR_IMAGE_PROC_CPU), MP_ROM_INT(IMAGE_PROC_CPU)}, {MP_OBJ_NEW_QSTR(MP_QSTR_IMAGE_PROC_OPENCV), MP_ROM_INT(IMAGE_PROC_OPENCV)}, {MP_OBJ_NEW_QSTR(MP_QSTR_IMAGE_PROC_HAL), MP_ROM_INT(IMAGE_PROC_HAL)}, {MP_OBJ_NEW_QSTR(MP_QSTR_IMAGE_PROC_MAX), MP_ROM_INT(IMAGE_PROC_MAX)}, {MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&imageproc_obj_open)}, {MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&imageproc_obj_close)}, {MP_ROM_QSTR(MP_QSTR_cvtColor), MP_ROM_PTR(&imageproc_obj_cvtColor)}, {MP_ROM_QSTR(MP_QSTR_resize), MP_ROM_PTR(&imageproc_obj_resize)}, {MP_ROM_QSTR(MP_QSTR_imgCopy), MP_ROM_PTR(&imageproc_obj_imgCopy)}, {MP_ROM_QSTR(MP_QSTR_rectangle), MP_ROM_PTR(&imageproc_obj_rectangle)}, {MP_ROM_QSTR(MP_QSTR_circle), MP_ROM_PTR(&imageproc_obj_circle)}, {MP_ROM_QSTR(MP_QSTR_drawMarker), MP_ROM_PTR(&imageproc_obj_drawMarker)}, {MP_ROM_QSTR(MP_QSTR_fillPoly), MP_ROM_PTR(&imageproc_obj_fillPoly)}, {MP_ROM_QSTR(MP_QSTR_putText), MP_ROM_PTR(&imageproc_obj_putText)}, {MP_ROM_QSTR(MP_QSTR_dilateErode), MP_ROM_PTR(&imageproc_obj_dilateErode)}, {MP_ROM_QSTR(MP_QSTR_imageAdd), MP_ROM_PTR(&imageproc_obj_imageAdd)}, {MP_ROM_QSTR(MP_QSTR_imageMinus), MP_ROM_PTR(&imageproc_obj_imageMinus)}, {MP_ROM_QSTR(MP_QSTR_imageElementMultiply), MP_ROM_PTR(&imageproc_obj_imageElementMultiply)}, {MP_ROM_QSTR(MP_QSTR_imageElementDivide), MP_ROM_PTR(&imageproc_obj_imageElementDivide)}, {MP_ROM_QSTR(MP_QSTR_writeImageToFile), MP_ROM_PTR(&imageproc_obj_writeImageToFile)}, }; STATIC MP_DEFINE_CONST_DICT(imageproc_locals_dict, imageproc_locals_dict_table); const mp_obj_type_t minicv_imageproc_type = { .base = {&mp_type_type}, .name = MP_QSTR_ImageProc, .print = imageproc_obj_print, .make_new = imageproc_obj_make_new, .locals_dict = (mp_obj_dict_t *)&imageproc_locals_dict, };
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/imageproc.c
C
apache-2.0
23,621
#include <stdio.h> #include <string.h> #include <stdlib.h> #include "py/mperrno.h" #include "py/obj.h" #include "py/runtime.h" #include "py/builtin.h" #include "base/modules/c/include/WrapperIHaasML.h" #include "ulog/ulog.h" #include "ucloud_ai_common.h" #define LOG_TAG "ML" extern const mp_obj_type_t minicv_ml_type; // this is the actual C-structure for our new object typedef struct { // base represents some basic information, like type mp_obj_base_t Base; // a member created by us char *ModuleName; MLEngineType_t mType; void *mInstance; char *mNetName; } mp_ml_obj_t; static mp_obj_t callback = mp_const_none; void ml_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { LOGD(LOG_TAG, "entern %s;\n", __func__); mp_ml_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_printf(print, "ModuleName(%s)", self->ModuleName); } STATIC mp_obj_t ml_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s;\n", __func__); mp_ml_obj_t *driver_obj = m_new_obj(mp_ml_obj_t); if (!driver_obj) { mp_raise_OSError(MP_EINVAL); } driver_obj->Base.type = &minicv_ml_type; driver_obj->ModuleName = "minicv-ML"; driver_obj->mType = ML_ENGINE_NONE; driver_obj->mInstance = NULL; return MP_OBJ_FROM_PTR(driver_obj); } STATIC mp_obj_t obj_open(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void *instance = NULL; if (n_args < 2) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_ml_obj_t *driver_obj = (mp_ml_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance != NULL) { LOGE(LOG_TAG, "Module has been opened, please clode first\n"); return mp_const_none; } driver_obj->mType = (MLEngineType_t)mp_obj_get_int(args[1]); LOGD(LOG_TAG, "%s:mType = %d;\n", __func__, driver_obj->mType); instance = MLCreateInstance(driver_obj->mType); driver_obj->mInstance = instance; if (instance == NULL) { LOGE(LOG_TAG, "MLCreateInstance failed\n"); return mp_const_none; } LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(ml_obj_open, 2, obj_open); STATIC mp_obj_t obj_close(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void *instance = NULL; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_ml_obj_t *driver_obj = (mp_ml_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has not been opened, not need close\n"); return mp_const_none; } MLDestoryInstance(driver_obj->mInstance); driver_obj->mType = ML_ENGINE_NONE; driver_obj->mInstance = NULL; LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(ml_obj_close, 1, obj_close); STATIC mp_obj_t obj_config(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void *instance = NULL; if (n_args < 5) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_ml_obj_t *driver_obj = (mp_ml_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } char *key = (mp_obj_get_type(args[1]) == &mp_type_NoneType) ? NULL : (char *)mp_obj_str_get_str(args[1]); char *secret = (mp_obj_get_type(args[2]) == &mp_type_NoneType) ? NULL : (char *)mp_obj_str_get_str(args[2]); char *endpoint = (mp_obj_get_type(args[3]) == &mp_type_NoneType) ? NULL : (char *)mp_obj_str_get_str(args[3]); char *bucket = (mp_obj_get_type(args[4]) == &mp_type_NoneType) ? NULL : (char *)mp_obj_str_get_str(args[4]); LOGD(LOG_TAG, "key = %s;\n", key); LOGD(LOG_TAG, "secret = %s;\n", secret); LOGD(LOG_TAG, "endpoint = %s;\n", endpoint); LOGD(LOG_TAG, "bucket = %s;\n", bucket); ret = MLConfig(driver_obj->mInstance, key, secret, endpoint, bucket); if (ret != 0) { LOGE(LOG_TAG, "MLConfig failed\n"); return mp_const_none; } return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(ml_obj_config, 5, obj_config); STATIC mp_obj_t obj_setInputData(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void *instance = NULL; if (n_args < 2) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_ml_obj_t *driver_obj = (mp_ml_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } char *mFileName = NULL; char *mFileName2 = NULL; if (n_args == 2) { mFileName = (char *)mp_obj_str_get_str(args[1]); } else if (n_args > 2) { mFileName = (char *)mp_obj_str_get_str(args[1]); mFileName2 = (mp_obj_get_type(args[2]) == &mp_type_NoneType) ? NULL : (char *)mp_obj_str_get_str(args[2]); } ret = MLSetInputData(driver_obj->mInstance, mFileName, mFileName2); if (ret != 0) { LOGE(LOG_TAG, "MLSetInputData failed mFileName = %s, mFileName2: %s;\n", mFileName, mFileName2); return mp_const_none; } LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(ml_obj_setInputData, 2, 3, obj_setInputData); STATIC mp_obj_t obj_loadNet(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void *instance = NULL; if (n_args < 2) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_ml_obj_t *driver_obj = (mp_ml_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } driver_obj->mNetName = (char *)mp_obj_str_get_str(args[1]); LOGD(LOG_TAG, "mNetName = %s;\n", driver_obj->mNetName); ret = MLLoadNet(driver_obj->mInstance, driver_obj->mNetName); if (ret != 0) { LOGE(LOG_TAG, "MLLoadNet failed mNetName = %s;\n", driver_obj->mNetName); return mp_const_none; } LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(ml_obj_loadNet, 2, obj_loadNet); STATIC mp_obj_t obj_predict(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void *instance = NULL; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_ml_obj_t *driver_obj = (mp_ml_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } MP_THREAD_GIL_EXIT(); ret = MLPredict(driver_obj->mInstance); MP_THREAD_GIL_ENTER(); if (ret != 0) { LOGE(LOG_TAG, "MLPredict failed\n"); return mp_const_none; } LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(ml_obj_predict, 1, obj_predict); STATIC mp_obj_t obj_getPredictResponses(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void *instance = NULL; mp_obj_t ret_list = mp_obj_new_list(0, NULL); if (n_args < 2) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_ml_obj_t *driver_obj = (mp_ml_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } if (args[1] != mp_const_none) { mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_WRITE); memset(bufinfo.buf, 0, bufinfo.len); LOGD(LOG_TAG, "bufinfo.buf = %p;bufinfo.len = %d;\n", bufinfo.buf, bufinfo.len); ret = MLGetPredictResponses(driver_obj->mInstance, &bufinfo.buf, &bufinfo.len); if (ret != 0) { LOGE(LOG_TAG, "MLGetPredictResponses failed\n"); } LOGD(LOG_TAG, "bufinfo.buf = %s;bufinfo.len = %d;\n", bufinfo.buf, bufinfo.len); LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return mp_const_none; } else { if (driver_obj->mType == ML_ENGINE_CLOUD) { int i = 0, ret_len = 0; ucloud_ai_result_t result[16]; memset(result, 0, sizeof(ucloud_ai_result_t) * 16); if (!strcmp(driver_obj->mNetName, "FacebodyComparing")) { ret_len = MLGetPredictResponses(driver_obj->mInstance, (char *)&result[0], sizeof(ucloud_ai_result_t)); if (ret_len <= 0) { LOGE(LOG_TAG, "MLGetPredictResponses failed\n"); return mp_const_none; } mp_obj_t dict = mp_obj_new_dict(5); i = 0; LOGD(LOG_TAG, "%.1f\n", result[i].facebody.face.confidence); LOGD(LOG_TAG, "x: %.1f\n", result[i].facebody.face.location.x); LOGD(LOG_TAG, "y: %.1f\n", result[i].facebody.face.location.y); LOGD(LOG_TAG, "w: %.1f\n", result[i].facebody.face.location.w); LOGD(LOG_TAG, "h: %.1f\n", result[i].facebody.face.location.h); mp_obj_dict_store(dict, MP_OBJ_NEW_QSTR(qstr_from_str("confidence")), mp_obj_new_float(result[i].facebody.face.confidence)); mp_obj_dict_store(dict, MP_OBJ_NEW_QSTR(qstr_from_str("x")), mp_obj_new_float(result[i].facebody.face.location.x)); mp_obj_dict_store(dict, MP_OBJ_NEW_QSTR(qstr_from_str("y")), mp_obj_new_float(result[i].facebody.face.location.y)); mp_obj_dict_store(dict, MP_OBJ_NEW_QSTR(qstr_from_str("w")), mp_obj_new_float(result[i].facebody.face.location.w)); mp_obj_dict_store(dict, MP_OBJ_NEW_QSTR(qstr_from_str("h")), mp_obj_new_float(result[i].facebody.face.location.h)); return dict; } else if (!strcmp(driver_obj->mNetName, "DetectFruits")) { ret_len = MLGetPredictResponses(driver_obj->mInstance, (char *)&result[0], sizeof(ucloud_ai_result_t) * 16); if (ret_len <= 0) { LOGE(LOG_TAG, "MLGetPredictResponses failed\n"); return mp_const_none; } mp_obj_t dict = mp_obj_new_dict(6); mp_obj_t ret_list = mp_obj_new_list(0, NULL); for (i = 0; i < ret_len; i++) { LOGD(LOG_TAG, "name: %s\n", result[i].imagerecog.fruits.name); LOGD(LOG_TAG, "score: %.1f\n", result[i].imagerecog.fruits.score); LOGD(LOG_TAG, "x: %.1f\n", result[i].imagerecog.fruits.box.x); LOGD(LOG_TAG, "y: %.1f\n", result[i].imagerecog.fruits.box.y); LOGD(LOG_TAG, "w: %.1f\n", result[i].imagerecog.fruits.box.w); LOGD(LOG_TAG, "h: %.1f\n", result[i].imagerecog.fruits.box.h); mp_obj_dict_store(dict, MP_OBJ_NEW_QSTR(qstr_from_str("name")), mp_obj_new_strn(result[i].imagerecog.fruits.name)); mp_obj_dict_store(dict, MP_OBJ_NEW_QSTR(qstr_from_str("score")), mp_obj_new_float(result[i].imagerecog.fruits.score)); mp_obj_dict_store(dict, MP_OBJ_NEW_QSTR(qstr_from_str("x")), mp_obj_new_float(result[i].imagerecog.fruits.box.x)); mp_obj_dict_store(dict, MP_OBJ_NEW_QSTR(qstr_from_str("y")), mp_obj_new_float(result[i].facebody.face.location.y)); mp_obj_dict_store(dict, MP_OBJ_NEW_QSTR(qstr_from_str("w")), mp_obj_new_float(result[i].facebody.face.location.w)); mp_obj_dict_store(dict, MP_OBJ_NEW_QSTR(qstr_from_str("h")), mp_obj_new_float(result[i].facebody.face.location.h)); mp_obj_list_append(ret_list, dict); } return ret_list; } else if (!strcmp(driver_obj->mNetName, "DetectPedestrian")) { ret_len = MLGetPredictResponses(driver_obj->mInstance, (char *)&result[0], sizeof(ucloud_ai_result_t) * 16); if (ret_len <= 0) { LOGE(LOG_TAG, "MLGetPredictResponses failed\n"); return mp_const_none; } mp_obj_t dict = mp_obj_new_dict(6); mp_obj_t ret_list = mp_obj_new_list(0, NULL); for (i = 0; i < ret_len; i++) { LOGD(LOG_TAG, "type: %s\n", result[i].facebody.pedestrian.type); LOGD(LOG_TAG, "score: %.1f\n", result[i].facebody.pedestrian.score); LOGD(LOG_TAG, "x: %.1f\n", result[i].facebody.pedestrian.box.x); LOGD(LOG_TAG, "y: %.1f\n", result[i].facebody.pedestrian.box.y); LOGD(LOG_TAG, "w: %.1f\n", result[i].facebody.pedestrian.box.w); LOGD(LOG_TAG, "h: %.1f\n", result[i].facebody.pedestrian.box.h); mp_obj_dict_store(dict, MP_OBJ_NEW_QSTR(qstr_from_str("type")), mp_obj_new_strn(result[i].facebody.pedestrian.type)); mp_obj_dict_store(dict, MP_OBJ_NEW_QSTR(qstr_from_str("score")), mp_obj_new_float(result[i].facebody.pedestrian.score)); mp_obj_dict_store(dict, MP_OBJ_NEW_QSTR(qstr_from_str("x")), mp_obj_new_float(result[i].facebody.pedestrian.box.x)); mp_obj_dict_store(dict, MP_OBJ_NEW_QSTR(qstr_from_str("y")), mp_obj_new_float(result[i].facebody.pedestrian.box.y)); mp_obj_dict_store(dict, MP_OBJ_NEW_QSTR(qstr_from_str("w")), mp_obj_new_float(result[i].facebody.pedestrian.box.w)); mp_obj_dict_store(dict, MP_OBJ_NEW_QSTR(qstr_from_str("h")), mp_obj_new_float(result[i].facebody.pedestrian.box.h)); mp_obj_list_append(ret_list, dict); } return ret_list; } else if (!strcmp(driver_obj->mNetName, "RecognizeLicensePlate")) { ret_len = MLGetPredictResponses(driver_obj->mInstance, (char *)&result[0], sizeof(ucloud_ai_result_t) * 16); if (ret_len <= 0) { LOGE(LOG_TAG, "MLGetPredictResponses failed\n"); return mp_const_none; } mp_obj_t dict = mp_obj_new_dict(8); mp_obj_t ret_list = mp_obj_new_list(0, NULL); for (i = 0; i < ret_len; i++) { LOGD(LOG_TAG, "plateNumber: %s\n", result[i].ocr.licensePlate.plateNumber); LOGD(LOG_TAG, "confidence: %.1f\n", result[i].ocr.licensePlate.confidence); LOGD(LOG_TAG, "plateType: %s\n", result[i].ocr.licensePlate.plateType); LOGD(LOG_TAG, "plateTypeConfidence: %.1f\n", result[i].ocr.licensePlate.plateTypeConfidence); LOGD(LOG_TAG, "x: %d\n", result[i].ocr.licensePlate.roi.x); LOGD(LOG_TAG, "y: %d\n", result[i].ocr.licensePlate.roi.y); LOGD(LOG_TAG, "w: %d\n", result[i].ocr.licensePlate.roi.w); LOGD(LOG_TAG, "h: %.1f\n", result[i].ocr.licensePlate.roi.h); mp_obj_dict_store(dict, MP_OBJ_NEW_QSTR(qstr_from_str("plateNumber")), mp_obj_new_strn(result[i].ocr.licensePlate.plateNumber)); mp_obj_dict_store(dict, MP_OBJ_NEW_QSTR(qstr_from_str("confidence")), mp_obj_new_float(result[i].ocr.licensePlate.confidence)); mp_obj_dict_store(dict, MP_OBJ_NEW_QSTR(qstr_from_str("plateType")), mp_obj_new_strn(result[i].ocr.licensePlate.plateType)); mp_obj_dict_store(dict, MP_OBJ_NEW_QSTR(qstr_from_str("plateTypeConfidence")), mp_obj_new_float(result[i].ocr.licensePlate.plateTypeConfidence)); mp_obj_dict_store(dict, MP_OBJ_NEW_QSTR(qstr_from_str("x")), mp_obj_new_int(result[i].ocr.licensePlate.roi.x)); mp_obj_dict_store(dict, MP_OBJ_NEW_QSTR(qstr_from_str("y")), mp_obj_new_int(result[i].ocr.licensePlate.roi.y)); mp_obj_dict_store(dict, MP_OBJ_NEW_QSTR(qstr_from_str("w")), mp_obj_new_int(result[i].ocr.licensePlate.roi.w)); mp_obj_dict_store(dict, MP_OBJ_NEW_QSTR(qstr_from_str("h")), mp_obj_new_int(result[i].ocr.licensePlate.roi.h)); mp_obj_list_append(ret_list, dict); } return ret_list; } } else { return mp_const_none; } } return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(ml_obj_getPredictResponses, 2, obj_getPredictResponses); STATIC mp_obj_t obj_unLoadNet(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void *instance = NULL; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]); mp_ml_obj_t *driver_obj = (mp_ml_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } ret = MLUnLoadNet(driver_obj->mInstance); if (ret != 0) { LOGE(LOG_TAG, "MLUnLoadNet failed\n"); return mp_const_none; } LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(ml_obj_unLoadNet, 1, obj_unLoadNet); STATIC const mp_rom_map_elem_t ml_locals_dict_table[] = { {MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ML)}, {MP_OBJ_NEW_QSTR(MP_QSTR_ML_ENGINE_NONE), MP_ROM_INT(ML_ENGINE_NONE)}, {MP_OBJ_NEW_QSTR(MP_QSTR_ML_ENGINE_MNN), MP_ROM_INT(ML_ENGINE_MNN)}, {MP_OBJ_NEW_QSTR(MP_QSTR_ML_ENGINE_CLOUD), MP_ROM_INT(ML_ENGINE_CLOUD)}, {MP_OBJ_NEW_QSTR(MP_QSTR_ML_ENGINE_ODLA), MP_ROM_INT(ML_ENGINE_ODLA)}, {MP_OBJ_NEW_QSTR(MP_QSTR_ML_ENGINE_MAX), MP_ROM_INT(ML_ENGINE_MAX)}, {MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&ml_obj_open)}, {MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&ml_obj_close)}, {MP_ROM_QSTR(MP_QSTR_config), MP_ROM_PTR(&ml_obj_config)}, {MP_ROM_QSTR(MP_QSTR_setInputData), MP_ROM_PTR(&ml_obj_setInputData)}, {MP_ROM_QSTR(MP_QSTR_loadNet), MP_ROM_PTR(&ml_obj_loadNet)}, {MP_ROM_QSTR(MP_QSTR_predict), MP_ROM_PTR(&ml_obj_predict)}, {MP_ROM_QSTR(MP_QSTR_getPredictResponses), MP_ROM_PTR(&ml_obj_getPredictResponses)}, {MP_ROM_QSTR(MP_QSTR_unLoadNet), MP_ROM_PTR(&ml_obj_unLoadNet)}, }; STATIC MP_DEFINE_CONST_DICT(ml_locals_dict, ml_locals_dict_table); const mp_obj_type_t minicv_ml_type = { .base = {&mp_type_type}, .name = MP_QSTR_ML, .print = ml_obj_print, .make_new = ml_obj_make_new, .locals_dict = (mp_obj_dict_t *)&ml_locals_dict, };
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/ml.c
C
apache-2.0
22,106
#include <stdio.h> #include <string.h> #include <stdlib.h> #if MICROPY_PY_MINICV #include "py/obj.h" #include "py/runtime.h" #include "py/builtin.h" #include "ulog/ulog.h" extern const mp_obj_type_t minicv_datainput_type; extern const mp_obj_type_t minicv_imagecodec_type; extern const mp_obj_type_t minicv_imageproc_type; extern const mp_obj_type_t minicv_ml_type; extern const mp_obj_type_t minicv_ui_type; extern const mp_obj_type_t minicv_videocodec_type; STATIC const mp_rom_map_elem_t minicv_module_globals_table[] = { {MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_minicv)}, {MP_OBJ_NEW_QSTR(MP_QSTR_DataInput), MP_ROM_PTR(&minicv_datainput_type)}, {MP_OBJ_NEW_QSTR(MP_QSTR_ImageCodec), MP_ROM_PTR(&minicv_imagecodec_type)}, {MP_OBJ_NEW_QSTR(MP_QSTR_ImageProc), MP_ROM_PTR(&minicv_imageproc_type)}, {MP_OBJ_NEW_QSTR(MP_QSTR_ML), MP_ROM_PTR(&minicv_ml_type)}, {MP_OBJ_NEW_QSTR(MP_QSTR_UI), MP_ROM_PTR(&minicv_ui_type)}, {MP_OBJ_NEW_QSTR(MP_QSTR_VideoCodec), MP_ROM_PTR(&minicv_videocodec_type)}, }; STATIC MP_DEFINE_CONST_DICT(minicv_module_globals, minicv_module_globals_table); const mp_obj_module_t minicv_module = { .base = {&mp_type_module}, .globals = (mp_obj_dict_t *)&minicv_module_globals, }; MP_REGISTER_MODULE(MP_QSTR_minicv, minicv_module, MICROPY_PY_MINICV); #endif // MICROPY_PY_MINICV
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/modminicv.c
C
apache-2.0
1,360
#include <stdio.h> #include <string.h> #include <stdlib.h> #include "py/mperrno.h" #include "py/obj.h" #include "py/runtime.h" #include "py/builtin.h" #include "ulog/ulog.h" #include "base/modules/c/include/WrapperIHaasUI.h" #define LOG_TAG "UI" extern const mp_obj_type_t minicv_ui_type; // this is the actual C-structure for our new object typedef struct { // base represents some basic information, like type mp_obj_base_t Base; // a member created by us char *ModuleName; UIFrameworkType_t mType; void *mInstance; } mp_ui_obj_t; void ui_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { LOGD(LOG_TAG, "entern %s;\n", __func__); mp_ui_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_printf(print, "ModuleName(%s)", self->ModuleName); } STATIC mp_obj_t ui_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s;\n", __func__); mp_ui_obj_t* driver_obj = m_new_obj(mp_ui_obj_t); if (!driver_obj) { mp_raise_OSError(MP_EINVAL); } driver_obj->Base.type = &minicv_ui_type; driver_obj->ModuleName = "minicv-UI"; driver_obj->mType = UI_FRAMEWORK_NONE; driver_obj->mInstance = NULL; return MP_OBJ_FROM_PTR(driver_obj); } STATIC mp_obj_t obj_open(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; if (n_args < 2) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_ui_obj_t* driver_obj = (mp_ui_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance != NULL) { LOGE(LOG_TAG, "Module has been opened, please clode first\n"); return mp_const_none; } driver_obj->mType = (UIFrameworkType_t)mp_obj_get_int(args[1]); LOGD(LOG_TAG, "%s:mType = %d;\n", __func__, driver_obj->mType); void *instance = UICreateInstance(driver_obj->mType); driver_obj->mInstance = instance; if (instance == NULL) { LOGE(LOG_TAG, "MLCreateInstance failed\n"); return mp_const_none; } LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(ui_obj_open, 2, obj_open); STATIC mp_obj_t obj_close(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_ui_obj_t* driver_obj = (mp_ui_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has not been opened, not need close\n"); return mp_const_none; } UIDestoryInstance(driver_obj->mInstance); driver_obj->mType = UI_FRAMEWORK_NONE; driver_obj->mInstance = NULL; LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(ui_obj_close, 1, obj_close); STATIC mp_obj_t obj_getDisplayWidth(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_ui_obj_t* driver_obj = (mp_ui_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } ret = UIGetDisplayWidth(driver_obj->mInstance); LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(ui_obj_getDisplayWidth, 1, obj_getDisplayWidth); STATIC mp_obj_t obj_getDisplayHeight(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_ui_obj_t* driver_obj = (mp_ui_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } ret = UIGetDisplayHeight(driver_obj->mInstance); LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(ui_obj_getDisplayHeight, 1, obj_getDisplayHeight); STATIC mp_obj_t obj_getDisplayBacklight(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_ui_obj_t* driver_obj = (mp_ui_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } ret = UIGetDisplayBacklight(driver_obj->mInstance); LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(ui_obj_getDisplayBacklight, 1, obj_getDisplayBacklight); STATIC mp_obj_t obj_setDisplayBacklight(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; if (n_args < 2) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_ui_obj_t* driver_obj = (mp_ui_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } int32_t value = (int32_t)mp_obj_get_int(args[1]); ret = UISetDisplayBacklight(driver_obj->mInstance, value); LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(ui_obj_setDisplayBacklight, 2, obj_setDisplayBacklight); STATIC mp_obj_t obj_getDisplayType(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_ui_obj_t* driver_obj = (mp_ui_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } ret = UIGetDisplayType(driver_obj->mInstance); LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(ui_obj_getDisplayType, 1, obj_getDisplayType); STATIC mp_obj_t obj_getDisplayFreq(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_ui_obj_t* driver_obj = (mp_ui_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } ret = UIGetDisplayFreq(driver_obj->mInstance); LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(ui_obj_getDisplayFreq, 1, obj_getDisplayFreq); STATIC mp_obj_t obj_setDisplayFreq(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; if (n_args < 2) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_ui_obj_t* driver_obj = (mp_ui_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } int32_t value = (int32_t)mp_obj_get_int(args[1]); ret = UISetDisplayFreq(driver_obj->mInstance, value); LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(ui_obj_setDisplayFreq, 2, obj_setDisplayFreq); STATIC mp_obj_t obj_drawPoint(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; if (n_args < 4) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_ui_obj_t* driver_obj = (mp_ui_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } uint32_t x = (uint32_t)mp_obj_get_int(args[1]); uint32_t y = (uint32_t)mp_obj_get_int(args[2]); int32_t color = (int32_t)mp_obj_get_int(args[3]); Point_t pt; pt.x = x; pt.y = y; ret = UIDrawPoint(driver_obj->mInstance, &pt, color); LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(ui_obj_drawPoint, 4, obj_drawPoint); STATIC mp_obj_t obj_drawLine(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; if (n_args < 6) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_ui_obj_t* driver_obj = (mp_ui_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } uint32_t startx = (uint32_t)mp_obj_get_int(args[1]); uint32_t starty = (uint32_t)mp_obj_get_int(args[2]); uint32_t endx = (uint32_t)mp_obj_get_int(args[3]); uint32_t endy = (uint32_t)mp_obj_get_int(args[4]); int32_t color = (int32_t)mp_obj_get_int(args[5]); Point_t start_pt; Point_t end_pt; start_pt.x = startx; start_pt.y = starty; end_pt.x = endx; end_pt.y = endy; ret = UIDrawLine(driver_obj->mInstance, &start_pt, &end_pt, color); LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(ui_obj_drawLine, 6, obj_drawLine); STATIC mp_obj_t obj_drawRectangle(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; if (n_args < 6) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_ui_obj_t* driver_obj = (mp_ui_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } int32_t left = (int32_t)mp_obj_get_int(args[1]); int32_t top = (int32_t)mp_obj_get_int(args[2]); int32_t right = (int32_t)mp_obj_get_int(args[3]); int32_t bottom = (int32_t)mp_obj_get_int(args[4]); int32_t color = (int32_t)mp_obj_get_int(args[5]); ret = UIDrawRectangle(driver_obj->mInstance, left, top, right, bottom, color); LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(ui_obj_drawRectangle, 6, obj_drawRectangle); STATIC mp_obj_t obj_drawCircle(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; if (n_args < 5) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_ui_obj_t* driver_obj = (mp_ui_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } uint32_t x = (uint32_t)mp_obj_get_int(args[1]); uint32_t y = (uint32_t)mp_obj_get_int(args[2]); int32_t radius = (int32_t)mp_obj_get_int(args[3]); int32_t color = (int32_t)mp_obj_get_int(args[4]); Point_t pt; pt.x = x; pt.y = y; ret = UIDrawCircle(driver_obj->mInstance, &pt, radius, color); LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(ui_obj_drawCircle, 5, obj_drawCircle); STATIC mp_obj_t obj_drawText(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; if (n_args < 8) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_ui_obj_t* driver_obj = (mp_ui_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } char* text = (char*)mp_obj_str_get_str(args[1]); int32_t size = (int32_t)mp_obj_get_int(args[2]); int32_t color = (int32_t)mp_obj_get_int(args[3]); int32_t left = (int32_t)mp_obj_get_int(args[4]); int32_t top = (int32_t)mp_obj_get_int(args[5]); int32_t right = (int32_t)mp_obj_get_int(args[6]); int32_t bottom = (int32_t)mp_obj_get_int(args[7]); UIDrawText(driver_obj->mInstance, text, size, color, left, top, right, bottom); LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(ui_obj_drawText, 8, obj_drawText); STATIC mp_obj_t obj_drawPixels(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; if (n_args < 6) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_ui_obj_t* driver_obj = (mp_ui_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } int32_t* pixels = (int32_t*)MP_OBJ_TO_PTR(args[1]); uint32_t x = (uint32_t)mp_obj_get_int(args[2]); uint32_t y = (uint32_t)mp_obj_get_int(args[3]); int32_t width = (int32_t)mp_obj_get_int(args[4]); int32_t height = (int32_t)mp_obj_get_int(args[5]); Point_t pt; pt.x = x; pt.y = y; ret = UIDrawPixels(driver_obj->mInstance, pixels, &pt, width, height); LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(ui_obj_drawPixels, 6, obj_drawPixels); STATIC mp_obj_t obj_drawImage(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; if (n_args < 6) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_ui_obj_t* driver_obj = (mp_ui_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } char* path = (char*)mp_obj_str_get_str(args[1]); uint32_t x = (uint32_t)mp_obj_get_int(args[2]); uint32_t y = (uint32_t)mp_obj_get_int(args[3]); int32_t width = (int32_t)mp_obj_get_int(args[4]); int32_t height = (int32_t)mp_obj_get_int(args[5]); Point_t pt; pt.x = x; pt.y = y; ret = UIDrawImage(driver_obj->mInstance, path, &pt, width, height); LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(ui_obj_drawImage, 6, obj_drawImage); STATIC mp_obj_t obj_updateDisplay(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_ui_obj_t* driver_obj = (mp_ui_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } UIUpdateDisplay(driver_obj->mInstance); LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(ui_obj_updateDisplay, 1, obj_updateDisplay); STATIC const mp_rom_map_elem_t ui_locals_dict_table[] = { {MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_UI)}, {MP_OBJ_NEW_QSTR(MP_QSTR_UI_FRAMEWORK_NONE), MP_ROM_INT(UI_FRAMEWORK_NONE)}, {MP_OBJ_NEW_QSTR(MP_QSTR_UI_FRAMEWORK_GREENUI), MP_ROM_INT(UI_FRAMEWORK_GREENUI)}, {MP_OBJ_NEW_QSTR(MP_QSTR_UI_FRAMEWORK_FB), MP_ROM_INT(UI_FRAMEWORK_FB)}, {MP_OBJ_NEW_QSTR(MP_QSTR_UI_FRAMEWORK_LVGL), MP_ROM_INT(UI_FRAMEWORK_LVGL)}, {MP_OBJ_NEW_QSTR(MP_QSTR_UI_FRAMEWORK_SDL), MP_ROM_INT(UI_FRAMEWORK_SDL)}, {MP_OBJ_NEW_QSTR(MP_QSTR_UI_FRAMEWORK_MAX), MP_ROM_INT(UI_FRAMEWORK_MAX)}, {MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&ui_obj_open)}, {MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&ui_obj_close)}, {MP_ROM_QSTR(MP_QSTR_getDisplayWidth), MP_ROM_PTR(&ui_obj_getDisplayWidth)}, {MP_ROM_QSTR(MP_QSTR_getDisplayHeight), MP_ROM_PTR(&ui_obj_getDisplayHeight)}, {MP_ROM_QSTR(MP_QSTR_getDisplayBacklight), MP_ROM_PTR(&ui_obj_getDisplayBacklight)}, {MP_ROM_QSTR(MP_QSTR_setDisplayBacklight), MP_ROM_PTR(&ui_obj_setDisplayBacklight)}, {MP_ROM_QSTR(MP_QSTR_getDisplayType), MP_ROM_PTR(&ui_obj_getDisplayType)}, {MP_ROM_QSTR(MP_QSTR_getDisplayFreq), MP_ROM_PTR(&ui_obj_getDisplayFreq)}, {MP_ROM_QSTR(MP_QSTR_setDisplayFreq), MP_ROM_PTR(&ui_obj_setDisplayFreq)}, {MP_ROM_QSTR(MP_QSTR_drawPoint), MP_ROM_PTR(&ui_obj_drawPoint)}, {MP_ROM_QSTR(MP_QSTR_drawLine), MP_ROM_PTR(&ui_obj_drawLine)}, {MP_ROM_QSTR(MP_QSTR_drawRectangle), MP_ROM_PTR(&ui_obj_drawRectangle)}, {MP_ROM_QSTR(MP_QSTR_drawCircle), MP_ROM_PTR(&ui_obj_drawCircle)}, {MP_ROM_QSTR(MP_QSTR_drawText), MP_ROM_PTR(&ui_obj_drawText)}, {MP_ROM_QSTR(MP_QSTR_drawPixels), MP_ROM_PTR(&ui_obj_drawPixels)}, {MP_ROM_QSTR(MP_QSTR_drawImage), MP_ROM_PTR(&ui_obj_drawImage)}, {MP_ROM_QSTR(MP_QSTR_updateDisplay), MP_ROM_PTR(&ui_obj_updateDisplay)}, }; STATIC MP_DEFINE_CONST_DICT(ui_locals_dict, ui_locals_dict_table); const mp_obj_type_t minicv_ui_type = { .base = {&mp_type_type}, .name = MP_QSTR_UI, .print = ui_obj_print, .make_new = ui_obj_make_new, .locals_dict = (mp_obj_dict_t *)&ui_locals_dict, };
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/ui.c
C
apache-2.0
21,571
#include <stdio.h> #include <string.h> #include <stdlib.h> #include "py/mperrno.h" #include "py/obj.h" #include "py/runtime.h" #include "py/builtin.h" #include "ulog/ulog.h" #include "base/modules/c/include/WrapperIHaasVideoCodec.h" #define LOG_TAG "VIDEO_CODEC" extern const mp_obj_type_t minicv_videocodec_type; // this is the actual C-structure for our new object typedef struct { // base represents some basic information, like type mp_obj_base_t Base; // a member created by us char *ModuleName; VideoCodecType_t mType; void *mInstance; } mp_videocodec_obj_t; void videocodec_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { LOGD(LOG_TAG, "entern %s;\n", __func__); mp_videocodec_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_printf(print, "ModuleName(%s)", self->ModuleName); } STATIC mp_obj_t videocodec_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s;\n", __func__); mp_videocodec_obj_t* driver_obj = m_new_obj(mp_videocodec_obj_t); if (!driver_obj) { mp_raise_OSError(MP_EINVAL); } driver_obj->Base.type = &minicv_videocodec_type; driver_obj->ModuleName = "HaasCV-VideoCodec"; driver_obj->mType = VIDEO_CODEC_NONE; driver_obj->mInstance = NULL; return MP_OBJ_FROM_PTR(driver_obj); } STATIC mp_obj_t obj_open(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 2) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_videocodec_obj_t* driver_obj = (mp_videocodec_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance != NULL) { LOGE(LOG_TAG, "Module has been opened, please clode first\n"); return mp_const_none; } driver_obj->mType = (VideoCodecType_t)mp_obj_get_int(args[1]); LOGD(LOG_TAG, "%s:mType = %d;\n", __func__, driver_obj->mType); instance = VideoCodecCreateInstance(driver_obj->mType); driver_obj->mInstance = instance; if (instance == NULL) { LOGE(LOG_TAG, "MLCreateInstance failed\n"); return mp_const_none; } ret = VideoCodecOpen(driver_obj->mInstance); LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(videocodec_obj_open, 2, obj_open); STATIC mp_obj_t obj_close(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_videocodec_obj_t* driver_obj = (mp_videocodec_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has not been opened, not need close\n"); return mp_const_none; } VideoCodecClose(driver_obj->mInstance); VideoCodecDestoryInstance(driver_obj->mInstance); driver_obj->mType = VIDEO_CODEC_NONE; driver_obj->mInstance = NULL; LOGD(LOG_TAG, "%s:out\n", __func__); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(videocodec_obj_close, 1, obj_close); STATIC mp_obj_t obj_decodeConfig(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 2) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_videocodec_obj_t* driver_obj = (mp_videocodec_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } DecodeConfig_t* config = (DecodeConfig_t*)MP_OBJ_TO_PTR(args[1]); ret = VideoCodecDecodeConfig(driver_obj->mInstance, config); LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(videocodec_obj_decodeConfig, 2, obj_decodeConfig); STATIC mp_obj_t obj_startDecode(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_videocodec_obj_t* driver_obj = (mp_videocodec_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } ret = VideoCodecStartDecode(driver_obj->mInstance); LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(videocodec_obj_startDecode, 1, obj_startDecode); STATIC mp_obj_t obj_stopDecode(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_videocodec_obj_t* driver_obj = (mp_videocodec_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } ret = VideoCodecStopDecode(driver_obj->mInstance); LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(videocodec_obj_stopDecode, 1, obj_stopDecode); STATIC mp_obj_t obj_getDecodeImageData(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 2) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_videocodec_obj_t* driver_obj = (mp_videocodec_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } ImageBuffer_t* image = NULL; void *pkt = (void *)MP_OBJ_TO_PTR(args[1]); ret = VideoCodecGetDecodeImageData(driver_obj->mInstance, pkt, &image); LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return MP_OBJ_FROM_PTR(image); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(videocodec_obj_getDecodeImageData, 2, obj_getDecodeImageData); STATIC mp_obj_t obj_encodeConfig(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 2) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_videocodec_obj_t* driver_obj = (mp_videocodec_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } EncodeConfig_t* config = (EncodeConfig_t*)MP_OBJ_TO_PTR(args[1]); ret = VideoCodecEncodeConfig(driver_obj->mInstance, config); LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(videocodec_obj_encodeConfig, 2, obj_encodeConfig); STATIC mp_obj_t obj_startEncode(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_videocodec_obj_t* driver_obj = (mp_videocodec_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } ret = VideoCodecStartEncode(driver_obj->mInstance); LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(videocodec_obj_startEncode, 1, obj_startEncode); STATIC mp_obj_t obj_stopEncode(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_videocodec_obj_t* driver_obj = (mp_videocodec_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } ret = VideoCodecStopEncode(driver_obj->mInstance); LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return MP_ROM_INT(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(videocodec_obj_stopEncode, 1, obj_stopEncode); STATIC mp_obj_t obj_getEncodePacketData(size_t n_args, const mp_obj_t *args) { LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args); int ret = -1; void* instance = NULL; if (n_args < 1) { LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args); return mp_const_none; } mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_videocodec_obj_t* driver_obj = (mp_videocodec_obj_t *)self; if (driver_obj == NULL) { LOGE(LOG_TAG, "driver_obj is NULL\n"); return mp_const_none; } if (driver_obj->mInstance == NULL) { LOGE(LOG_TAG, "Module has been closed, please open first\n"); return mp_const_none; } VideoPacket_t *data = NULL; ret = VideoCodecGetEncodePacketData(driver_obj->mInstance, &data); LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret); return MP_OBJ_FROM_PTR(data); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(videocodec_obj_getEncodePacketData, 1, obj_getEncodePacketData); STATIC const mp_rom_map_elem_t videocodec_locals_dict_table[] = { {MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_VideoCodec)}, {MP_OBJ_NEW_QSTR(MP_QSTR_VIDEO_CODEC_NONE), MP_ROM_INT(VIDEO_CODEC_NONE)}, {MP_OBJ_NEW_QSTR(MP_QSTR_VIDEO_CODEC_FFMPEG), MP_ROM_INT(VIDEO_CODEC_FFMPEG)}, {MP_OBJ_NEW_QSTR(MP_QSTR_VIDEO_CODEC_HAL), MP_ROM_INT(VIDEO_CODEC_HAL)}, {MP_OBJ_NEW_QSTR(MP_QSTR_VIDEO_CODEC_MAX), MP_ROM_INT(VIDEO_CODEC_MAX)}, {MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&videocodec_obj_open)}, {MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&videocodec_obj_close)}, {MP_ROM_QSTR(MP_QSTR_decodeConfig), MP_ROM_PTR(&videocodec_obj_decodeConfig)}, {MP_ROM_QSTR(MP_QSTR_startDecode), MP_ROM_PTR(&videocodec_obj_startDecode)}, {MP_ROM_QSTR(MP_QSTR_stopDecode), MP_ROM_PTR(&videocodec_obj_stopDecode)}, {MP_ROM_QSTR(MP_QSTR_getDecodeImageData), MP_ROM_PTR(&videocodec_obj_getDecodeImageData)}, {MP_ROM_QSTR(MP_QSTR_encodeConfig), MP_ROM_PTR(&videocodec_obj_encodeConfig)}, {MP_ROM_QSTR(MP_QSTR_startEncode), MP_ROM_PTR(&videocodec_obj_startEncode)}, {MP_ROM_QSTR(MP_QSTR_stopEncode), MP_ROM_PTR(&videocodec_obj_stopEncode)}, {MP_ROM_QSTR(MP_QSTR_getEncodePacketData), MP_ROM_PTR(&videocodec_obj_getEncodePacketData)}, }; STATIC MP_DEFINE_CONST_DICT(videocodec_locals_dict, videocodec_locals_dict_table); const mp_obj_type_t minicv_videocodec_type = { .base = {&mp_type_type}, .name = MP_QSTR_VideoCodec, .print = videocodec_obj_print, .make_new = videocodec_obj_make_new, .locals_dict = (mp_obj_dict_t *)&videocodec_locals_dict, };
YifuLiu/AliOS-Things
components/py_engine/modules/minicv/videocodec.c
C
apache-2.0
13,366
#include <stdio.h> #include <stdlib.h> #include <string.h> #if MICROPY_PY_MODBUS #include "board_mgr.h" #include "mbmaster.h" #include "py/builtin.h" #include "py/obj.h" #include "py/runtime.h" #include "py/stackctrl.h" #include "ulog/ulog.h" #define LOG_TAG "modbus" static mb_handler_t *mb_handler = NULL; STATIC mp_int_t parser_from_board_configuration_file(const char *id, modbus_dev_t *dev) { item_handle_t modbus_handle; mp_int_t ret = py_board_mgr_init(); if (ret != 0) { LOGE(LOG_TAG, "%s:py_board_mgr_init failed\n", __func__); goto out; } ret = py_board_attach_item(MODULE_MODBUS, id, &modbus_handle); if (ret != 0) { LOGE(LOG_TAG, "%s: py_board_attach_item failed ret = %d;\n", __func__, ret); goto out; } modbus_dev_t *modbus_device = py_board_get_node_by_handle(MODULE_MODBUS, &modbus_handle); if (!modbus_device) { LOGE(LOG_TAG, "%s: py_board_get_node_by_handle failed;\n", __func__); } else { memcpy(dev, modbus_device, sizeof(modbus_dev_t)); } out: if (0 != ret) { py_board_disattach_item(MODULE_MODBUS, &modbus_handle); } return ret; } STATIC mp_obj_t mp_modbus_init(size_t n_args, const mp_obj_t *args) { if (n_args != 1) { mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("Should input 1 string argument")); return mp_const_none; } if (mb_handler != NULL) { mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("Device busy, deinit firstly")); return MP_OBJ_NEW_SMALL_INT(-EBUSY); } const char *node_name = mp_obj_str_get_str(args[0]); if (node_name == NULL) { LOGE(LOG_TAG, "node_name null !!!!\n"); return MP_OBJ_NEW_SMALL_INT(-EINVAL); } modbus_dev_t dev = { .mode = MBMODE_SERIAL, .port = 1, .baudrate = 9600, .parity = MB_PAR_NONE, .timeout = 200, }; mp_int_t status = parser_from_board_configuration_file(node_name, &dev); if (status != 0) { return MP_OBJ_NEW_SMALL_INT(status); } if (dev.mode == MBMODE_NET) { status = EOPNOTSUPP; } else { status = mbmaster_rtu_init(&mb_handler, dev.port, dev.baudrate, dev.parity, dev.timeout); } return MP_OBJ_NEW_SMALL_INT(-status); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_modbus_init_obj, 0, 4, mp_modbus_init); STATIC mp_obj_t mp_modbus_deinit(size_t n_args, const mp_obj_t *args) { if (mb_handler == NULL) { mp_raise_OSError(EBADF); return mp_const_none; } mp_int_t status = mbmaster_rtu_uninit(mb_handler); if (status == MB_SUCCESS) { mb_handler = NULL; } return MP_OBJ_NEW_SMALL_INT(-status); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(mp_modbus_deinit_obj, 0, mp_modbus_deinit); STATIC mp_obj_t mp_writeHoldingRegister(size_t n_args, const mp_obj_t *args) { if (n_args != 4) { mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("Should input 4 args")); return mp_const_none; } uint32_t timeout; uint16_t resp_addr = 0; uint8_t exception_code = 0; uint16_t resp_data = 0; uint8_t slave_addr = mp_obj_get_int(args[0]); uint16_t register_addr = mp_obj_get_int(args[1]); uint16_t register_value = mp_obj_get_int(args[2]); int t = mp_obj_get_int(args[3]); if (t < 0) { timeout = AOS_WAIT_FOREVER; } else { timeout = t; } mb_status_t status = mbmaster_write_single_register(mb_handler, slave_addr, register_addr, register_value, &resp_addr, &resp_data, &exception_code, timeout); if (status == MB_SUCCESS && register_value == resp_data) { LOGD(LOG_TAG, "write single register ok"); } else { LOGE(LOG_TAG, "write single register error"); } mp_obj_t tuple[4] = { MP_OBJ_NEW_SMALL_INT(-status), mp_obj_new_int_from_uint(resp_addr), mp_obj_new_int_from_uint(resp_data), mp_obj_new_int_from_uint(exception_code), }; return mp_obj_new_tuple(4, tuple); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(mp_writeHoldingRegister_obj, 4, mp_writeHoldingRegister); STATIC mp_obj_t mp_writeMultipleHoldingRegisters(size_t n_args, const mp_obj_t *args) { if (n_args != 5) { mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("Should input 5 args")); return mp_const_none; } uint16_t resp_addr = 0; uint16_t resp_quantity = 0; uint8_t exception_code = 0; uint8_t slave_addr = mp_obj_get_int(args[0]); uint16_t start_addr = mp_obj_get_int(args[1]); uint16_t reg_quantity = mp_obj_get_int(args[2]); mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[3], &bufinfo, MP_BUFFER_READ); if (bufinfo.len < reg_quantity) { mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("bytearray size should not smaller than " "twice of reg_quantity")); return mp_const_none; } uint32_t timeout; int t = mp_obj_get_int(args[4]); if (t < 0) { timeout = AOS_WAIT_FOREVER; } else { timeout = t; } mb_status_t status = mbmaster_write_multiple_registers(mb_handler, slave_addr, start_addr, reg_quantity, bufinfo.buf, &resp_addr, &resp_quantity, &exception_code, timeout); if (status != MB_SUCCESS) { LOGE(LOG_TAG, "WriteMultipleHoldingRegisters error"); } mp_obj_t tuple[4] = { MP_OBJ_NEW_SMALL_INT(-status), mp_obj_new_int_from_uint(resp_addr), mp_obj_new_int_from_uint(resp_quantity), mp_obj_new_int_from_uint(exception_code), }; return mp_obj_new_tuple(4, tuple); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(mp_writeMultipleHoldingRegisters_obj, 5, mp_writeMultipleHoldingRegisters); STATIC mp_obj_t mp_writeCoil(size_t n_args, const mp_obj_t *args) { if (n_args != 4) { mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("Should input 4 args")); return mp_const_none; } uint16_t resp_addr = 0; uint16_t resp_value = 0; uint8_t exception_code = 0; uint8_t slave_addr = mp_obj_get_int(args[0]); uint16_t coil_addr = mp_obj_get_int(args[1]); uint16_t coil_value = mp_obj_get_int(args[2]); uint32_t timeout; int t = mp_obj_get_int(args[3]); if (t < 0) { timeout = AOS_WAIT_FOREVER; } else { timeout = t; } mb_status_t status = mbmaster_write_single_coil(mb_handler, slave_addr, coil_addr, coil_value, &resp_addr, &resp_value, &exception_code, timeout); if (status != MB_SUCCESS || coil_value != resp_value) { LOGE(LOG_TAG, "write single register error"); } mp_obj_t tuple[4] = { MP_OBJ_NEW_SMALL_INT(-status), mp_obj_new_int_from_uint(resp_addr), mp_obj_new_int_from_uint(resp_value), mp_obj_new_int_from_uint(exception_code), }; return mp_obj_new_tuple(4, tuple); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(mp_writeCoil_obj, 4, mp_writeCoil); STATIC mp_obj_t mp_writeMultipleCoils(size_t n_args, const mp_obj_t *args) { if (n_args != 5) { mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("Should input 5 args")); return mp_const_none; } uint16_t resp_addr = 0; uint16_t resp_quantity = 0; uint8_t exception_code = 0; uint8_t slave_addr = mp_obj_get_int(args[0]); uint16_t start_addr = mp_obj_get_int(args[1]); uint16_t reg_quantity = mp_obj_get_int(args[2]); mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[3], &bufinfo, MP_BUFFER_READ); uint32_t timeout; int t = mp_obj_get_int(args[4]); if (t < 0) { timeout = AOS_WAIT_FOREVER; } else { timeout = t; } mb_status_t status = mbmaster_write_multiple_coils(mb_handler, slave_addr, start_addr, reg_quantity, bufinfo.buf, &resp_addr, &resp_quantity, &exception_code, timeout); if (status != MB_SUCCESS) { LOGE(LOG_TAG, "writeMultipleCoils error"); } mp_obj_t tuple[4] = { MP_OBJ_NEW_SMALL_INT(-status), mp_obj_new_int_from_uint(resp_addr), mp_obj_new_int_from_uint(resp_quantity), mp_obj_new_int_from_uint(exception_code), }; return mp_obj_new_tuple(4, tuple); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(mp_writeMultipleCoils_obj, 5, mp_writeMultipleCoils); STATIC mp_obj_t mp_readHoldingRegisters(size_t n_args, const mp_obj_t *args) { if (n_args != 5) { mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("Should input 5 args")); return mp_const_none; } uint8_t resp_quantity = 0; uint8_t slave_addr = mp_obj_get_int(args[0]); uint16_t start_addr = mp_obj_get_int(args[1]); uint16_t reg_quantity = mp_obj_get_int(args[2]); mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[3], &bufinfo, MP_BUFFER_WRITE); uint32_t timeout; int t = mp_obj_get_int(args[4]); if (t < 0) { timeout = AOS_WAIT_FOREVER; } else { timeout = t; } mb_status_t status = mbmaster_read_holding_registers(mb_handler, slave_addr, start_addr, reg_quantity, bufinfo.buf, &resp_quantity, timeout); if (status != MB_SUCCESS) { LOGE(LOG_TAG, "readHoldingRegisters error"); } mp_obj_t tuple[2] = { MP_OBJ_NEW_SMALL_INT(-status), mp_obj_new_int_from_uint(resp_quantity), }; return mp_obj_new_tuple(2, tuple); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(mp_readHoldingRegisters_obj, 5, mp_readHoldingRegisters); STATIC mp_obj_t mp_readInputRegisters(size_t n_args, const mp_obj_t *args) { if (n_args != 5) { mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("Should input 5 args")); return mp_const_none; } uint8_t resp_quantity = 0; uint8_t slave_addr = mp_obj_get_int(args[0]); uint16_t start_addr = mp_obj_get_int(args[1]); uint16_t reg_quantity = mp_obj_get_int(args[2]); mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[3], &bufinfo, MP_BUFFER_WRITE); uint32_t timeout; int t = mp_obj_get_int(args[4]); if (t < 0) { timeout = AOS_WAIT_FOREVER; } else { timeout = t; } mb_status_t status = mbmaster_read_input_registers(mb_handler, slave_addr, start_addr, reg_quantity, bufinfo.buf, &resp_quantity, timeout); if (status != MB_SUCCESS) { LOGE(LOG_TAG, "readInputRegisters error"); } mp_obj_t tuple[2] = { MP_OBJ_NEW_SMALL_INT(-status), mp_obj_new_int_from_uint(resp_quantity), }; return mp_obj_new_tuple(2, tuple); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(mp_readInputRegisters_obj, 5, mp_readInputRegisters); STATIC mp_obj_t mp_readDiscreteInputs(size_t n_args, const mp_obj_t *args) { if (n_args != 5) { mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("Should input 5 args")); return mp_const_none; } uint8_t resp_quantity = 0; uint8_t slave_addr = mp_obj_get_int(args[0]); uint16_t start_addr = mp_obj_get_int(args[1]); uint16_t reg_quantity = mp_obj_get_int(args[2]); mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[3], &bufinfo, MP_BUFFER_WRITE); uint32_t timeout; int t = mp_obj_get_int(args[4]); if (t < 0) { timeout = AOS_WAIT_FOREVER; } else { timeout = t; } mb_status_t status = mbmaster_read_discrete_inputs(mb_handler, slave_addr, start_addr, reg_quantity, bufinfo.buf, &resp_quantity, timeout); if (status != MB_SUCCESS) { LOGE(LOG_TAG, "readDiscreteInputs error"); } mp_obj_t tuple[2] = { MP_OBJ_NEW_SMALL_INT(-status), mp_obj_new_int_from_uint(resp_quantity), }; return mp_obj_new_tuple(2, tuple); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(mp_readDiscreteInputs_obj, 5, mp_readDiscreteInputs); STATIC mp_obj_t mp_readCoils(size_t n_args, const mp_obj_t *args) { if (n_args != 5) { mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("Should input 5 args")); return mp_const_none; } uint8_t resp_quantity = 0; uint8_t slave_addr = mp_obj_get_int(args[0]); uint16_t start_addr = mp_obj_get_int(args[1]); uint16_t reg_quantity = mp_obj_get_int(args[2]); mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[3], &bufinfo, MP_BUFFER_WRITE); uint32_t timeout; int t = mp_obj_get_int(args[4]); if (t < 0) { timeout = AOS_WAIT_FOREVER; } else { timeout = t; } mb_status_t status = mbmaster_read_coils(mb_handler, slave_addr, start_addr, reg_quantity, bufinfo.buf, &resp_quantity, timeout); if (status != MB_SUCCESS) { LOGE(LOG_TAG, "read_coils error"); } mp_obj_t tuple[2] = { MP_OBJ_NEW_SMALL_INT(-status), mp_obj_new_int_from_uint(resp_quantity), }; return mp_obj_new_tuple(2, tuple); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(mp_readCoils_obj, 5, mp_readCoils); STATIC mp_obj_t mp_slave_framerecv(size_t n_args, const mp_obj_t *args) { if (mb_handler == NULL) { mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("slave not inited")); return mp_const_none; } // 1. recv frame from master MP_THREAD_GIL_EXIT(); mb_status_t status = mb_handler->frame_recv(mb_handler); MP_THREAD_GIL_ENTER(); if (status == MB_SUCCESS) { // 2. disassemble frame status = mb_handler->adu_disassemble(mb_handler); if (status != MB_SUCCESS) { LOGE(LOG_TAG, "Failed to disassemble frame"); } } mp_obj_t tuple[2]; tuple[0] = MP_OBJ_NEW_SMALL_INT(-status); tuple[1] = status == MB_SUCCESS ? mp_obj_new_bytes(mb_handler->mb_frame_buff, mb_handler->mb_frame_length) : mp_const_none; return mp_obj_new_tuple(2, tuple); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(mp_slave_framerecv_obj, 0, mp_slave_framerecv); STATIC mp_obj_t mp_slave_framesend(size_t n_args, const mp_obj_t *args) { if (mb_handler == NULL) { mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("slave not inited")); return mp_const_none; } uint16_t slave_addr = mp_obj_get_int(args[0]); mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_READ); uint32_t timeout; int t = mp_obj_get_int(args[2]); if (t < 0) { timeout = AOS_WAIT_FOREVER; } else { timeout = t; } mb_handler->slave_addr = slave_addr; mb_handler->pdu_length = bufinfo.len; memcpy(&mb_handler->mb_frame_buff[ADU_SER_PDU_OFF], bufinfo.buf, bufinfo.len); mb_status_t status = mb_handler->adu_assemble(mb_handler); MP_THREAD_GIL_EXIT(); status = mb_handler->frame_send(mb_handler, timeout); MP_THREAD_GIL_ENTER(); if (status != MB_SUCCESS) { LOGE(LOG_TAG, "frame send failed"); } mp_obj_t tuple[2] = { MP_OBJ_NEW_SMALL_INT(-status), mp_obj_new_int_from_uint(mb_handler->mb_frame_length), }; return mp_obj_new_tuple(2, tuple); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(mp_slave_framesend_obj, 2, mp_slave_framesend); STATIC const mp_rom_map_elem_t modbus_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_modbus) }, { MP_OBJ_NEW_QSTR(MP_QSTR_init), MP_ROM_PTR(&mp_modbus_init_obj) }, { MP_OBJ_NEW_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&mp_modbus_deinit_obj) }, { MP_OBJ_NEW_QSTR(MP_QSTR_writeHoldingRegister), MP_ROM_PTR(&mp_writeHoldingRegister_obj) }, { MP_OBJ_NEW_QSTR(MP_QSTR_writeMultipleHoldingRegisters), MP_ROM_PTR(&mp_writeMultipleHoldingRegisters_obj) }, { MP_OBJ_NEW_QSTR(MP_QSTR_writeCoil), MP_ROM_PTR(&mp_writeCoil_obj) }, { MP_OBJ_NEW_QSTR(MP_QSTR_writeMultipleCoils), MP_ROM_PTR(&mp_writeMultipleCoils_obj) }, { MP_OBJ_NEW_QSTR(MP_QSTR_readHoldingRegisters), MP_ROM_PTR(&mp_readHoldingRegisters_obj) }, { MP_OBJ_NEW_QSTR(MP_QSTR_readInputRegisters), MP_ROM_PTR(&mp_readInputRegisters_obj) }, { MP_OBJ_NEW_QSTR(MP_QSTR_readDiscreteInputs), MP_ROM_PTR(&mp_readDiscreteInputs_obj) }, { MP_OBJ_NEW_QSTR(MP_QSTR_readCoils), MP_ROM_PTR(&mp_readCoils_obj) }, { MP_OBJ_NEW_QSTR(MP_QSTR_recv), MP_ROM_PTR(&mp_slave_framerecv_obj) }, { MP_OBJ_NEW_QSTR(MP_QSTR_send), MP_ROM_PTR(&mp_slave_framesend_obj) }, { MP_ROM_QSTR(MP_QSTR_PARITY_NONE), MP_ROM_INT(MB_PAR_NONE) }, { MP_ROM_QSTR(MP_QSTR_PARITY_ODD), MP_ROM_INT(MB_PAR_ODD) }, { MP_ROM_QSTR(MP_QSTR_PARITY_EVEN), MP_ROM_INT(MB_PAR_EVEN) }, }; STATIC MP_DEFINE_CONST_DICT(modbus_module_globals, modbus_module_globals_table); const mp_obj_module_t mp_module_modbus = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&modbus_module_globals, }; MP_REGISTER_MODULE(MP_QSTR_modbus, mp_module_modbus, MICROPY_PY_MODBUS); #endif // MICROPY_PY_MODBUS
YifuLiu/AliOS-Things
components/py_engine/modules/modbus/modbus.c
C
apache-2.0
17,015
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "py/builtin.h" #include "py/mperrno.h" #include "py/obj.h" #include "py/runtime.h" #include "ulog/ulog.h" extern const mp_obj_type_t mqtt_client_type; // this is the actual C-structure for our new object STATIC const mp_rom_map_elem_t mqtt_locals_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_http) }, { MP_OBJ_NEW_QSTR(MP_QSTR_client), MP_ROM_PTR(&mqtt_client_type) }, }; STATIC MP_DEFINE_CONST_DICT(mqtt_locals_dict, mqtt_locals_dict_table); const mp_obj_module_t mqtt_module = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&mqtt_locals_dict, };
YifuLiu/AliOS-Things
components/py_engine/modules/mqtt/modmqtt.c
C
apache-2.0
680