| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- /*
- * switch.c
- *
- * Created on: 2025年11月6日
- * Author: wulianwei
- */
- #include "nim_config.h"
- #include "tr_protocol.h"
- extern volatile unsigned int TocuhTime; //触控时间
- extern volatile unsigned char TocuhTrigger; //触控触发
- static volatile char gui_power_status = 0; //gui开机状态,1:开机,0:关机
- void touch_opengui();
- void touch_deivce_init()
- {
- GPIOBank0Pin11Init();
- GPIOBank5Pin5Init();
- }
- /**
- * 中断调用函数,尽快结束
- */
- void touch_switch(int len)
- {
- if(len)
- {
- TocuhTrigger = 0;
- TocuhTime = TOUCH_TIME;
- ConsolePuts("swith 1", -1);
- }
- else
- {
- TocuhTrigger = 1;
- TocuhTime = TOUCH_TIME;
- ConsolePuts("swith 0", -1);
- }
- }
- /**
- * 设置gui电源状态
- */
- void setGuiPowerStatus(char value)
- {
- gui_power_status = value;
- }
- void touch_askgui()
- {
- trProtocol verPro;
- ProtocolInit(&verPro);
- ProtocolSetDestAddress(&verPro,3);
- ProtocolSetSourceAddress(&verPro,1);
- ProtocolSetType(&verPro,2);
- ProtocolSetOptionChar(&verPro, 99, 2);//关机请求
- ProtocolPackage(&verPro);
- ConsolePuts("\n===shutdown request to gui\n", -1);
- ConsolePutsHexStr(verPro.message, verPro.length);
- lwip_tcp_send_gui(verPro.message,verPro.length);
- }
- //gui上电
- void touch_opengui()
- {
- ConsolePuts("\n===open gui\n", -1);
- GPIOPinWrite(SOC_GPIO_0_REGS, 86, GPIO_PIN_HIGH); // GPIO5[5]
- gui_power_status = 1;
- init_ip();
- }
- //gui断电
- void touch_closegui()
- {
- ConsolePuts("\n===close gui\n", -1);
- GPIOPinWrite(SOC_GPIO_0_REGS, 86, GPIO_PIN_LOW);
- gui_power_status = 0;
- }
- void touch_task()
- {
- if(TocuhTime == 0)
- {
- TocuhTime = TOUCH_TIME;
- if(gui_power_status)
- {
- touch_askgui();
- }
- else
- {
- touch_opengui();
- }
- }
- }
|