添加了半成品的浇水部分,没有实际作用,目前浇水功能直接用硬件实现;
加入了对毕设论文的记录;
This commit is contained in:
parent
3b6408a650
commit
fe11958be3
17 changed files with 6973 additions and 6919 deletions
BIN
plan_manage_main/doc/宋星_毕设论文.docx
Normal file
BIN
plan_manage_main/doc/宋星_毕设论文.docx
Normal file
Binary file not shown.
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,24 +1,24 @@
|
|||
@REM This batch file has been generated by the IAR Embedded Workbench
|
||||
@REM C-SPY Debugger, as an aid to preparing a command line for running
|
||||
@REM the cspybat command line utility using the appropriate settings.
|
||||
@REM
|
||||
@REM Note that this file is generated every time a new debug session
|
||||
@REM is initialized, so you may want to move or rename the file before
|
||||
@REM making changes.
|
||||
@REM
|
||||
@REM You can launch cspybat by typing the name of this batch file followed
|
||||
@REM by the name of the debug file (usually an ELF/DWARF or UBROF file).
|
||||
@REM
|
||||
@REM Read about available command line parameters in the C-SPY Debugging
|
||||
@REM Guide. Hints about additional command line parameters that may be
|
||||
@REM useful in specific cases:
|
||||
@REM --download_only Downloads a code image without starting a debug
|
||||
@REM session afterwards.
|
||||
@REM --silent Omits the sign-on message.
|
||||
@REM --timeout Limits the maximum allowed execution time.
|
||||
@REM
|
||||
|
||||
|
||||
"D:\work_soft\iar\arm\common\bin\cspybat" "D:\work_soft\iar\arm\arm\bin\armproc.dll" "D:\work_soft\iar\arm\arm\bin\armjlink.dll" %1 --plugin "D:\work_soft\iar\arm\arm\bin\armbat.dll" --device_macro "D:\work_soft\iar\arm\arm\config\debugger\Freescale\Kinetis.dmac" --backend -B "--endian=little" "--cpu=Cortex-M0+" "--fpu=None" "-p" "D:\work_soft\iar\arm\arm\CONFIG\debugger\Freescale\MKL25Z128xxx4.ddf" "--semihosting" "--device=MKL25Z128xxx4" "--drv_mtb_regbase=0xF0000000" "--drv_mtb_dwtregbase=0xF0001000" "--drv_mtb_minramaddr=0x20000000" "--drv_mtb_maxramaddr=0x20002FFF" "--drv_communication=USB0" "--jlink_speed=auto" "--jlink_initial_speed=1000" "--jlink_reset_strategy=0,0" "--jlink_interface=SWD" "--drv_catch_exceptions=0x000" "--drv_swo_clock_setup=72000000,0,2000000"
|
||||
|
||||
|
||||
@REM This batch file has been generated by the IAR Embedded Workbench
|
||||
@REM C-SPY Debugger, as an aid to preparing a command line for running
|
||||
@REM the cspybat command line utility using the appropriate settings.
|
||||
@REM
|
||||
@REM Note that this file is generated every time a new debug session
|
||||
@REM is initialized, so you may want to move or rename the file before
|
||||
@REM making changes.
|
||||
@REM
|
||||
@REM You can launch cspybat by typing the name of this batch file followed
|
||||
@REM by the name of the debug file (usually an ELF/DWARF or UBROF file).
|
||||
@REM
|
||||
@REM Read about available command line parameters in the C-SPY Debugging
|
||||
@REM Guide. Hints about additional command line parameters that may be
|
||||
@REM useful in specific cases:
|
||||
@REM --download_only Downloads a code image without starting a debug
|
||||
@REM session afterwards.
|
||||
@REM --silent Omits the sign-on message.
|
||||
@REM --timeout Limits the maximum allowed execution time.
|
||||
@REM
|
||||
|
||||
|
||||
"D:\work_soft\iar\arm\common\bin\cspybat" "D:\work_soft\iar\arm\arm\bin\armproc.dll" "D:\work_soft\iar\arm\arm\bin\armjlink.dll" %1 --plugin "D:\work_soft\iar\arm\arm\bin\armbat.dll" --device_macro "D:\work_soft\iar\arm\arm\config\debugger\Freescale\Kinetis.dmac" --backend -B "--endian=little" "--cpu=Cortex-M0+" "--fpu=None" "-p" "D:\work_soft\iar\arm\arm\CONFIG\debugger\Freescale\MKL25Z128xxx4.ddf" "--semihosting" "--device=MKL25Z128xxx4" "--drv_mtb_regbase=0xF0000000" "--drv_mtb_dwtregbase=0xF0001000" "--drv_mtb_minramaddr=0x20000000" "--drv_mtb_maxramaddr=0x20002FFF" "--drv_communication=USB0" "--jlink_speed=auto" "--jlink_initial_speed=1000" "--jlink_reset_strategy=0,0" "--jlink_interface=SWD" "--drv_catch_exceptions=0x000" "--drv_swo_clock_setup=72000000,0,2000000"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
|
||||
<crun>
|
||||
<version>1</version>
|
||||
<filter_entries>
|
||||
<filter index="0" type="default">
|
||||
<type>*</type>
|
||||
<start_file>*</start_file>
|
||||
<end_file>*</end_file>
|
||||
<action_debugger>0</action_debugger>
|
||||
<action_log>1</action_log>
|
||||
</filter>
|
||||
</filter_entries>
|
||||
</crun>
|
||||
|
||||
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
|
||||
<crun>
|
||||
<version>1</version>
|
||||
<filter_entries>
|
||||
<filter index="0" type="default">
|
||||
<type>*</type>
|
||||
<start_file>*</start_file>
|
||||
<end_file>*</end_file>
|
||||
<action_debugger>0</action_debugger>
|
||||
<action_log>1</action_log>
|
||||
</filter>
|
||||
</filter_entries>
|
||||
</crun>
|
||||
|
||||
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,127 +1,118 @@
|
|||
[Stack]
|
||||
FillEnabled=0
|
||||
OverflowWarningsEnabled=1
|
||||
WarningThreshold=90
|
||||
SpWarningsEnabled=1
|
||||
WarnLogOnly=1
|
||||
UseTrigger=1
|
||||
TriggerName=main
|
||||
LimitSize=0
|
||||
ByteLimit=50
|
||||
[DebugChecksum]
|
||||
Checksum=-253352013
|
||||
[CodeCoverage]
|
||||
Enabled=_ 0
|
||||
[Exceptions]
|
||||
StopOnUncaught=_ 0
|
||||
StopOnThrow=_ 0
|
||||
[CallStack]
|
||||
ShowArgs=0
|
||||
[Disassembly]
|
||||
MixedMode=1
|
||||
[Interrupts]
|
||||
Enabled=1
|
||||
[MemConfig]
|
||||
Base=1
|
||||
Manual=0
|
||||
Ddf=1
|
||||
TypeViol=0
|
||||
Stop=1
|
||||
[Simulator]
|
||||
Freq=10000000
|
||||
MultiCoreRunAll=1
|
||||
[JLinkDriver]
|
||||
CStepIntDis=_ 0
|
||||
TraceBufferSize=0x00010000
|
||||
TraceStallIfFIFOFull=0x00000000
|
||||
TracePortSize=0x00000004
|
||||
[SWOTraceHWSettings]
|
||||
OverrideDefaultClocks=0
|
||||
CpuClock=72000000
|
||||
ClockAutoDetect=0
|
||||
ClockWanted=2000000
|
||||
JtagSpeed=2000000
|
||||
Prescaler=36
|
||||
TimeStampPrescIndex=0
|
||||
TimeStampPrescData=0
|
||||
PcSampCYCTAP=1
|
||||
PcSampPOSTCNT=15
|
||||
PcSampIndex=0
|
||||
DataLogMode=0
|
||||
ITMportsEnable=0
|
||||
ITMportsTermIO=0
|
||||
ITMportsLogFile=0
|
||||
ITMlogFile=$PROJ_DIR$\ITM.log
|
||||
[Trace1]
|
||||
Enabled=0
|
||||
ShowSource=1
|
||||
[Trace2]
|
||||
Enabled=0
|
||||
ShowSource=0
|
||||
[SWOTraceWindow]
|
||||
PcSampling=0
|
||||
InterruptLogs=0
|
||||
ForcedTimeStamps=0
|
||||
EventCPI=0
|
||||
EventEXC=0
|
||||
EventFOLD=0
|
||||
EventLSU=0
|
||||
EventSLEEP=0
|
||||
[PowerLog]
|
||||
LogEnabled=0
|
||||
GraphEnabled=0
|
||||
ShowTimeLog=1
|
||||
ShowTimeSum=0
|
||||
Title_0=I0
|
||||
Symbol_0=0 4 1
|
||||
LiveEnabled=0
|
||||
LiveFile=PowerLogLive.log
|
||||
[DataLog]
|
||||
LogEnabled=0
|
||||
SumEnabled=0
|
||||
GraphEnabled=0
|
||||
ShowTimeLog=1
|
||||
ShowTimeSum=1
|
||||
[EventLog]
|
||||
LogEnabled=0
|
||||
SumEnabled=0
|
||||
GraphEnabled=0
|
||||
ShowTimeLog=1
|
||||
ShowTimeSum=1
|
||||
SumSortOrder=0
|
||||
[InterruptLog]
|
||||
LogEnabled=0
|
||||
SumEnabled=0
|
||||
GraphEnabled=0
|
||||
ShowTimeLog=1
|
||||
ShowTimeSum=1
|
||||
SumSortOrder=0
|
||||
[Disassemble mode]
|
||||
mode=0
|
||||
[Breakpoints2]
|
||||
Bp0=_ 1 "EMUL_CODE" "{$PROJ_DIR$\..\src\app\tft.c}.728.13" 0 0 1 "" 0 "" 0
|
||||
Bp1=_ 1 "EMUL_CODE" "{$PROJ_DIR$\..\src\app\plan_handle.c}.213.5" 0 0 1 "" 0 "" 0
|
||||
Bp2=_ 1 "EMUL_CODE" "{$PROJ_DIR$\..\src\app\tft.c}.999.9" 0 0 1 "" 0 "" 0
|
||||
Count=3
|
||||
[Log file]
|
||||
LoggingEnabled=_ 0
|
||||
LogFile=_ ""
|
||||
Category=_ 0
|
||||
[TermIOLog]
|
||||
LoggingEnabled=_ 0
|
||||
LogFile=_ ""
|
||||
[Aliases]
|
||||
Count=0
|
||||
SuppressDialog=0
|
||||
[CallStackLog]
|
||||
Enabled=0
|
||||
[PowerProbe]
|
||||
Frequency=10000
|
||||
Probe0=I0
|
||||
ProbeSetup0=2 1 1 2 0 0
|
||||
[DriverProfiling]
|
||||
Enabled=0
|
||||
Mode=1
|
||||
Graph=0
|
||||
Symbiont=0
|
||||
Exclusions=
|
||||
[Stack]
|
||||
FillEnabled=0
|
||||
OverflowWarningsEnabled=1
|
||||
WarningThreshold=90
|
||||
SpWarningsEnabled=1
|
||||
WarnLogOnly=1
|
||||
UseTrigger=1
|
||||
TriggerName=main
|
||||
LimitSize=0
|
||||
ByteLimit=50
|
||||
[DebugChecksum]
|
||||
Checksum=231404021
|
||||
[CodeCoverage]
|
||||
Enabled=_ 0
|
||||
[Exceptions]
|
||||
StopOnUncaught=_ 0
|
||||
StopOnThrow=_ 0
|
||||
[CallStack]
|
||||
ShowArgs=0
|
||||
[Disassembly]
|
||||
MixedMode=1
|
||||
[Interrupts]
|
||||
Enabled=1
|
||||
[MemConfig]
|
||||
Base=1
|
||||
Manual=0
|
||||
Ddf=1
|
||||
TypeViol=0
|
||||
Stop=1
|
||||
[Simulator]
|
||||
Freq=10000000
|
||||
MultiCoreRunAll=1
|
||||
[JLinkDriver]
|
||||
CStepIntDis=_ 0
|
||||
TraceBufferSize=0x00010000
|
||||
TraceStallIfFIFOFull=0x00000000
|
||||
TracePortSize=0x00000004
|
||||
[SWOTraceHWSettings]
|
||||
OverrideDefaultClocks=0
|
||||
CpuClock=72000000
|
||||
ClockAutoDetect=0
|
||||
ClockWanted=2000000
|
||||
JtagSpeed=2000000
|
||||
Prescaler=36
|
||||
TimeStampPrescIndex=0
|
||||
TimeStampPrescData=0
|
||||
PcSampCYCTAP=1
|
||||
PcSampPOSTCNT=15
|
||||
PcSampIndex=0
|
||||
DataLogMode=0
|
||||
ITMportsEnable=0
|
||||
ITMportsTermIO=0
|
||||
ITMportsLogFile=0
|
||||
ITMlogFile=$PROJ_DIR$\ITM.log
|
||||
[SWOTraceWindow]
|
||||
PcSampling=0
|
||||
InterruptLogs=0
|
||||
ForcedTimeStamps=0
|
||||
EventCPI=0
|
||||
EventEXC=0
|
||||
EventFOLD=0
|
||||
EventLSU=0
|
||||
EventSLEEP=0
|
||||
[PowerLog]
|
||||
LogEnabled=0
|
||||
GraphEnabled=0
|
||||
ShowTimeLog=1
|
||||
ShowTimeSum=0
|
||||
Title_0=I0
|
||||
Symbol_0=0 4 1
|
||||
LiveEnabled=0
|
||||
LiveFile=PowerLogLive.log
|
||||
[DataLog]
|
||||
LogEnabled=0
|
||||
SumEnabled=0
|
||||
GraphEnabled=0
|
||||
ShowTimeLog=1
|
||||
ShowTimeSum=1
|
||||
[EventLog]
|
||||
LogEnabled=0
|
||||
SumEnabled=0
|
||||
GraphEnabled=0
|
||||
ShowTimeLog=1
|
||||
ShowTimeSum=1
|
||||
SumSortOrder=0
|
||||
[InterruptLog]
|
||||
LogEnabled=0
|
||||
SumEnabled=0
|
||||
GraphEnabled=0
|
||||
ShowTimeLog=1
|
||||
ShowTimeSum=1
|
||||
SumSortOrder=0
|
||||
[Log file]
|
||||
LoggingEnabled=_ 0
|
||||
LogFile=_ ""
|
||||
Category=_ 0
|
||||
[TermIOLog]
|
||||
LoggingEnabled=_ 0
|
||||
LogFile=_ ""
|
||||
[CallStackLog]
|
||||
Enabled=0
|
||||
[PowerProbe]
|
||||
Frequency=10000
|
||||
Probe0=I0
|
||||
ProbeSetup0=2 1 1 2 0 0
|
||||
[DriverProfiling]
|
||||
Enabled=0
|
||||
Mode=1
|
||||
Graph=0
|
||||
Symbiont=0
|
||||
Exclusions=
|
||||
[Disassemble mode]
|
||||
mode=0
|
||||
[Breakpoints2]
|
||||
Count=0
|
||||
[Aliases]
|
||||
Count=0
|
||||
SuppressDialog=0
|
||||
|
|
|
|||
|
|
@ -1,81 +1,83 @@
|
|||
/*
|
||||
* config.h - 配置整个工程
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
|
||||
|
||||
#define PM_DEBUG
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 模拟定时器使用的定时器
|
||||
*/
|
||||
#define SIMULAT_TIMER_PITX PIT1
|
||||
|
||||
|
||||
/*
|
||||
* 调试模块,或8266
|
||||
*/
|
||||
#define WIFI_UARTX UART0 // PTA1,PTA2
|
||||
#define DEBUG_UARTX UART0 // PTA1,PTA2
|
||||
|
||||
/*
|
||||
* 云台
|
||||
*/
|
||||
#define ORIENT_UARTX UART1 // PTC3,PTC4
|
||||
#define RE_DE_PINX PTC1
|
||||
|
||||
/*
|
||||
* 输入模块
|
||||
*/
|
||||
#define UP_KEY_PINX PTA4
|
||||
#define DOWN_KEY_PINX PTA5
|
||||
#define OK_KEY_PINX PTE20
|
||||
#define RET_KEY_PINX PTE30
|
||||
#define AMS_KEY_PINX PTD5
|
||||
#define WIFI_KEY_PINX PTD7
|
||||
#define MR_KEY_PINX PTE23
|
||||
#define MB_KEY_PINX PTD4
|
||||
#define MUVB_KEY_PINX PTA16
|
||||
// knob用必须是PTA或PTD端口的
|
||||
#define KNOB_A_PINX PTD7
|
||||
#define KNOB_B_PINX PTD6
|
||||
#define KNOB_KEY_PINX PTE20
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 显示模块
|
||||
*/
|
||||
#define TFT_UARTX UART2 // PTD2,PTD3
|
||||
|
||||
|
||||
/*
|
||||
* 时间模块
|
||||
*/
|
||||
#define DS1302_CE_PINX PTB2
|
||||
#define DS1302_CLK_PINX PTB1
|
||||
#define DS1302_IO_PINX PTB3
|
||||
|
||||
/*
|
||||
* 控制执行模块
|
||||
*
|
||||
*/
|
||||
#define LGRED_PINX PTC17
|
||||
#define LGBLUE_PINX PTC13
|
||||
#define LGUVB_PINX PTC16
|
||||
#define WATER_PINX PTD1
|
||||
|
||||
/*
|
||||
* led控制,多选几个任意端口
|
||||
*/
|
||||
#define LG1_PINX PTC9
|
||||
#define LG2_PINX PTC8
|
||||
#define LG3_PINX PTC7
|
||||
#endif // CONFIG_H
|
||||
/*
|
||||
* config.h - 配置整个工程
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
|
||||
|
||||
#define PM_DEBUG
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 模拟定时器使用的定时器
|
||||
*/
|
||||
#define SIMULAT_TIMER_PITX PIT1
|
||||
|
||||
|
||||
/*
|
||||
* 调试模块,或8266
|
||||
*/
|
||||
#define WIFI_UARTX UART0 // PTA1,PTA2
|
||||
#define DEBUG_UARTX UART0 // PTA1,PTA2
|
||||
|
||||
/*
|
||||
* 云台
|
||||
*/
|
||||
#define ORIENT_UARTX UART1 // PTC3,PTC4
|
||||
#define RE_DE_PINX PTC1
|
||||
|
||||
/*
|
||||
* 输入模块
|
||||
*/
|
||||
#define UP_KEY_PINX PTA4
|
||||
#define DOWN_KEY_PINX PTA5
|
||||
#define OK_KEY_PINX PTE20
|
||||
#define RET_KEY_PINX PTE30
|
||||
#define AMS_KEY_PINX PTD5
|
||||
#define WIFI_KEY_PINX PTD7
|
||||
#define MR_KEY_PINX PTE23
|
||||
#define MB_KEY_PINX PTD4
|
||||
#define MUVB_KEY_PINX PTA16
|
||||
// knob用必须是PTA或PTD端口的
|
||||
#define KNOB_A_PINX PTD7
|
||||
#define KNOB_B_PINX PTD6
|
||||
#define KNOB_KEY_PINX PTE20
|
||||
|
||||
#define MOISTURE_ADC0_CHN ADC0_DP1 // PTE16
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 显示模块
|
||||
*/
|
||||
#define TFT_UARTX UART2 // PTD2,PTD3
|
||||
|
||||
|
||||
/*
|
||||
* 时间模块
|
||||
*/
|
||||
#define DS1302_CE_PINX PTB2
|
||||
#define DS1302_CLK_PINX PTB1
|
||||
#define DS1302_IO_PINX PTB3
|
||||
|
||||
/*
|
||||
* 控制执行模块
|
||||
*
|
||||
*/
|
||||
#define LGRED_PINX PTC17
|
||||
#define LGBLUE_PINX PTC13
|
||||
#define LGUVB_PINX PTC16
|
||||
#define WATER_PINX PTD1
|
||||
|
||||
/*
|
||||
* led控制,多选几个任意端口
|
||||
*/
|
||||
#define LG1_PINX PTC9
|
||||
#define LG2_PINX PTC8
|
||||
#define LG3_PINX PTC7
|
||||
#endif // CONFIG_H
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
/*
|
||||
* 文件:input.h
|
||||
* 功能:将外设输入的数据转换为单片机内存中的数据
|
||||
*/
|
||||
|
||||
#ifndef INPUT_H
|
||||
#define INPUT_H
|
||||
|
||||
|
||||
typedef struct InData_
|
||||
{
|
||||
uint8_t isWifiOn : 1;
|
||||
uint8_t isPlanMode : 1;
|
||||
|
||||
uint8_t isRedL : 1;
|
||||
uint8_t isBlueL : 1;
|
||||
uint8_t isUvbL : 1;
|
||||
|
||||
uint8_t knobV;
|
||||
} InData;
|
||||
|
||||
|
||||
void InitInput(void);
|
||||
|
||||
void
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // INPUT_H
|
||||
32
plan_manage_main/src/app/include/water.h
Normal file
32
plan_manage_main/src/app/include/water.h
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* water.h - ½½Ë®
|
||||
*/
|
||||
|
||||
|
||||
#ifndef WARER_H
|
||||
#define WARER_H
|
||||
|
||||
|
||||
#define MOISTURE_RATIO 0.1
|
||||
#define MOISTURE_MIN 1
|
||||
|
||||
|
||||
|
||||
|
||||
void water_init(void);
|
||||
|
||||
|
||||
uint16_t get_moisture(void);
|
||||
|
||||
|
||||
void water_ctr(uint16_t sv_moist);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* WARER_H */
|
||||
|
|
@ -1,117 +1,106 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include "include/pm_init.h"
|
||||
#include "include/simulat_timer.h"
|
||||
#include "include/key.h"
|
||||
#include "include/knob.h"
|
||||
#include "include/tft.h"
|
||||
#include "include/config.h"
|
||||
#include "include/pm_time.h"
|
||||
#include "include/plan_handle.h"
|
||||
#include "include/pm_flash.h"
|
||||
#include "include/orient.h"
|
||||
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
|
||||
printf("\n\n\n程序开始执行!!!\n\n\n");
|
||||
enter_critical();
|
||||
pm_init();
|
||||
exit_critical();
|
||||
|
||||
st_init(0, COMPARE, 10); // 作为按键扫描函数的定时使用,在simulat_timer.c的底层中使用
|
||||
st_init(1, COMPARE, 100);
|
||||
|
||||
#ifdef PM_DEBUG
|
||||
st_init(2, COMPARE, 1);
|
||||
st_init(3, COMPARE, 500);
|
||||
#endif /* PM_DEBUG */
|
||||
|
||||
knob_enable();
|
||||
|
||||
|
||||
|
||||
|
||||
while (1)
|
||||
{
|
||||
/*
|
||||
* 时间以及计划处理
|
||||
*/
|
||||
if (st_tcf(1) == 1)
|
||||
{
|
||||
maintain_system_time();
|
||||
|
||||
calendar_info st= get_system_time();
|
||||
*get_value_of_kvp("st_y", 0) = st.year;
|
||||
*get_value_of_kvp("st_mo", 0) = st.month;
|
||||
*get_value_of_kvp("st_d", 0) = st.mday;
|
||||
*get_value_of_kvp("st_h", 0) = st.hour;
|
||||
*get_value_of_kvp("st_mi", 0) = st.min;
|
||||
*get_value_of_kvp("st_s", 0) = st.sec;
|
||||
tft_page_refresh();
|
||||
|
||||
plan_handle();
|
||||
}
|
||||
|
||||
#ifdef PM_DEBUG
|
||||
/*
|
||||
* 调试相关,较短时间响应
|
||||
*/
|
||||
if (st_tcf(2) == 1)
|
||||
{
|
||||
static int32_t log = 0, knob_v;
|
||||
if (log != (knob_v = get_knob_val()))
|
||||
{
|
||||
printf("knob = %d\n", knob_v);
|
||||
log = knob_v;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 调试相关,较长时间响应
|
||||
*/
|
||||
if (st_tcf(3) == 1)
|
||||
{
|
||||
calendar_info st = get_system_time();
|
||||
|
||||
printf("%d 年 %d 月 %d 星期 %d 日 %d 时 %d 分 %d 秒\n",
|
||||
st.year, st.month, st.wday, st.mday,
|
||||
st.hour, st.min, st.sec);
|
||||
printf("sec = %d\n", calendar_to_sec(&st));
|
||||
calendar_info test_t;
|
||||
test_t.year = 2016;
|
||||
test_t.month = 5;
|
||||
test_t.mday = 5;
|
||||
test_t.hour = 12;
|
||||
test_t.min = 25;
|
||||
test_t.sec = 0;
|
||||
uint32_t test_sec = calendar_to_sec(&test_t);
|
||||
printf("test_sec = %d\n", test_sec);
|
||||
|
||||
static uint8_t lg_test;
|
||||
lg_test = !lg_test;
|
||||
gpio_set(LG1_PINX, 0);
|
||||
gpio_set(LG2_PINX, 0);
|
||||
gpio_set(LG3_PINX, 0);
|
||||
|
||||
if (gpio_get(AMS_KEY_PINX))
|
||||
{
|
||||
printf("计划!!!!!!\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("手动!!!!!!\n");
|
||||
}
|
||||
}
|
||||
#endif /* PM_DEBUG */
|
||||
|
||||
key_func();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include "include/pm_init.h"
|
||||
#include "include/simulat_timer.h"
|
||||
#include "include/key.h"
|
||||
#include "include/knob.h"
|
||||
#include "include/tft.h"
|
||||
#include "include/config.h"
|
||||
#include "include/pm_time.h"
|
||||
#include "include/plan_handle.h"
|
||||
#include "include/pm_flash.h"
|
||||
#include "include/orient.h"
|
||||
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
|
||||
printf("\n\n\n程序开始执行!!!\n\n\n");
|
||||
enter_critical();
|
||||
pm_init();
|
||||
exit_critical();
|
||||
|
||||
st_init(0, COMPARE, 10); // 作为按键扫描函数的定时使用,在simulat_timer.c的底层中使用
|
||||
st_init(1, COMPARE, 100);
|
||||
|
||||
#ifdef PM_DEBUG
|
||||
st_init(2, COMPARE, 1);
|
||||
st_init(3, COMPARE, 500);
|
||||
#endif /* PM_DEBUG */
|
||||
|
||||
knob_enable();
|
||||
|
||||
|
||||
while (1)
|
||||
{
|
||||
/*
|
||||
* 时间以及计划处理
|
||||
*/
|
||||
if (st_tcf(1) == 1)
|
||||
{
|
||||
maintain_system_time();
|
||||
|
||||
calendar_info st= get_system_time();
|
||||
*get_value_of_kvp("st_y", 0) = st.year;
|
||||
*get_value_of_kvp("st_mo", 0) = st.month;
|
||||
*get_value_of_kvp("st_d", 0) = st.mday;
|
||||
*get_value_of_kvp("st_h", 0) = st.hour;
|
||||
*get_value_of_kvp("st_mi", 0) = st.min;
|
||||
*get_value_of_kvp("st_s", 0) = st.sec;
|
||||
tft_page_refresh();
|
||||
|
||||
plan_handle();
|
||||
}
|
||||
|
||||
#ifdef PM_DEBUG
|
||||
/*
|
||||
* 调试相关,较短时间响应
|
||||
*/
|
||||
if (st_tcf(2) == 1)
|
||||
{
|
||||
static int32_t log = 0, knob_v;
|
||||
if (log != (knob_v = get_knob_val()))
|
||||
{
|
||||
printf("knob = %d\n", knob_v);
|
||||
log = knob_v;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 调试相关,较长时间响应
|
||||
*/
|
||||
if (st_tcf(3) == 1)
|
||||
{
|
||||
calendar_info st = get_system_time();
|
||||
|
||||
printf("%d 年 %d 月 %d 星期 %d 日 %d 时 %d 分 %d 秒\n",
|
||||
st.year, st.month, st.wday, st.mday,
|
||||
st.hour, st.min, st.sec);
|
||||
printf("sec = %d\n", calendar_to_sec(&st));
|
||||
|
||||
static uint8_t lg_test;
|
||||
lg_test = !lg_test;
|
||||
gpio_set(LG1_PINX, 0);
|
||||
gpio_set(LG2_PINX, 0);
|
||||
gpio_set(LG3_PINX, 0);
|
||||
|
||||
if (gpio_get(AMS_KEY_PINX))
|
||||
{
|
||||
printf("计划!!!!!!\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("手动!!!!!!\n");
|
||||
}
|
||||
}
|
||||
#endif /* PM_DEBUG */
|
||||
|
||||
key_func();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
41
plan_manage_main/src/app/water.c
Normal file
41
plan_manage_main/src/app/water.c
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#include <stdint.h>
|
||||
|
||||
#include "adc.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "water.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void water_init(void)
|
||||
{
|
||||
gpio_init(WATER_PINX, 1, 1);
|
||||
adc_init(MOISTURE_ADC0_CHN);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
uint16_t get_moisture(void)
|
||||
{
|
||||
uint16_t res;
|
||||
|
||||
res = adc_ave(MOISTURE_ADC0_CHN, ADC_16bit, 3);
|
||||
return (uint16_t)((float)res / 0xffff * MOISTURE_RATIO + MOISTURE_MIN);
|
||||
}
|
||||
|
||||
void water_ctr(uint16_t sv_moist)
|
||||
{
|
||||
uint16_t crt_moist = get_moisture();
|
||||
|
||||
if (sv_moist > crt_moist)
|
||||
{
|
||||
gpio_set(WATER_PINX, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
gpio_set(WATER_PINX, 1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue