单⽚机c语⾔NTC温度查表程序,STM32查表法读NTC值并显⽰
温度
闭目养神STM32查表法读NTC值并显⽰温度
#include "stm32f10x.h"Y'+F0IZ+
#include "delay.h"pU'`9fLi_
#include "sys.h"tOlzOBzR
&j
wnM
#include "led.h"|{}d5Z"5;}
#include "key.h"P"h,[{Y*>
#include "lcd1602.h"{U+9,6.`
#include "fan.h"5Fl
#include "adc.h"
#include "ntc.h"hz>yv@1
0N}
wD-
Cx1Sh#9
3qV>TE]6,
严重eW }jS/g`
//#include "motor.h"K_w0+oYa
//************************************************************************JVIcNK)
rwV u?W
变幻莫测的意思/
/#define OVER_MENU 10 //定义⼀个数,判断这个数是否需要退出菜单设置l,FG:"`Z@
L;(3u'
//vu8 auto_return=0;Rp4BU"&sU
=O}%bZ)Q
L{o >D"
/********************** Hhce:E@K
* ⽬录结构体定义 * tr67ofld|
**********************/ _,-M8=dL%*
/*UU:QK{{E
struct MenuItemw!GU~0~3[
{ hnfrnYH
unsigned char MenuCount; //当前层节点数A)`fD
%+
unsigned char *DisplayString; //菜单标题Z({`9+/>u
首善之区void (*Subs)(); //节点函数]aMa*fF
获得免疫struct MenuItem *ChildrenMenus; //⼦节点)uv$tnP*
struct MenuItem *ParentMenus; //⽗节点fAA@ziKg
}; :8GxcqvCWq
-^nQ^Td=j
/*********************** :O@,Z_"
* 调⽤⼦函数区 * ;r@R (Squ
********************** */ JXa%TpI:
E
/*4*2>R8SX~
void NullSubs(void) l.W 1$g
{ =w>>7u$4
Ul~}@^m]4}
}URzE+8m^
M6 >\R$
[2fiHE
gQzJ2LU(
void MotorSetPWM(void)DuCu6j
{ HuLm!tCu
下水管漏水维修7!QXh;u
//不分频。PWM频率=72000000/900=80KhzsB1tce
//delay_ms(10); BrH`:Dw
TIM_SetCompare2(TIM4,100);cd%g]T)#1
2W-NCE%K)T
}f`";Q/rG
p-03V"^&
/*********************W&re;?Z{ke
@^4M~F%
//------------------------------------------------------------------------------3b/vyZF /*********************** ;cHI3V
* 结构体区 * kk7:A0._
***********************/ /v ;Kb|e
//----------------------以下为例⼦,请根据实际情况修改---------------------------n[w,x;
/*CzsY=DBH=
struct MenuItem TimeMenu[4];oX]1>#5UMg
struct MenuItem UvlampMenu[4];+Q#Qu0_
struct MenuItem UvfanMenu[4];F>-@LOqHy
台风泰培
struct MenuItem MotorMenu[5];,ce^"yG
struct MenuItem MainMenu[5];eJ\j{-
pxnUe1=
Y,Zv0-"
struct MenuItem TimeMenu[4]=&-)Y[#\J
{ //MenuCount DisplayString Subs ChildrenMenus ParentMenus1kw4'#J8 {4, "1.Time Set", NullSubs, Null, MainMenu},.t%Vx
{4, "2.OFF", NullSubs, Null, MainMenu},~ai'
M#
{4, "3.ON", NullSubs, Null, MainMenu},HnY"6gTNK
{4, "4.Back", NullSubs, MainMenu, MainMenu},DT]p14@t9
}; B]}V$*$\?
]M"'qC3g
r{jD,x2
struct MenuItem UvlampMenu[4]=Ck a]F2,
{ //MenuCount DisplayString Subs ChildrenMenus ParentMenusNn7@+g) {4, "1.UVlamp Set", NullSubs, Null, MainMenu},|(ju!&
{4, "2.OFF", UVlampSetOFF, Null, MainMenu},]TprPU39 {4, "3.ON", UVlampSetON, Null, MainMenu},/
{4, "4.Back", NullSubs, MainMenu, MainMenu},{hP&P
}; )P+GklI{4
'm?x2$u8
struct MenuItem UvfanMenu[4]=&_hCs![
{ //MenuCount DisplayString Subs ChildrenMenus ParentMenusnL20}"$E {4, "1.UVfan Set" , NullSubs, Null, MainMenu},c^gIK1f-
{4, "2.OFF", UVfanSetOFF, Null, MainMenu},D)Rf
{4, "3.ON", UVfanSetON, Null, MainMenu},z(68^-V=:
{4, "4.Back", NullSubs, MainMenu, MainMenu},Hu2g (!
}; Bzt`9lg
la 7QNQW
struct MenuItem MotorMenu[5]=F76h
{ //MenuCount DisplayString Subs ChildrenMenus ParentMenusfR;_6?p*B {5, "1.Motor Set", NullSubs, Null, MainMenu},ZTC1t_
{5, "2.Turnleft", MotorSetTurnleft, Null, MainMenu},]7
mSM
{5, "2.TurnRight", MotorSetTurnRight, Null, MainMenu},d+ko"F| {5, "4.OFF", MotorSetOFF, Null, MainMenu},shvcc
{5, "5.Back", NullSubs, MainMenu, MainMenu},Y.
tFqzo3
}; y.
'Rw]
C[
struct MenuItem MainMenu[5]=3(p6ak2lv
{ //MenuCount DisplayString Subs ChildrenMenus ParentMenus*uM*)6O3 {5, "1.Time Set" , NullSubs, TimeMenu, Null},g$LwXfg
{5, "2.UVlamp Set", NullSubs, UvlampMenu, Null},0J`/g H
{5, "3.UVfan Set", NullSubs, UvfanMenu, Null},k(+u"T
{5, "4.Motor Set", NullSubs, MotorMenu, Null},#;]F:TlR
{5, "5.Back", NullSubs, MainMenu, MainMenu},CxQ,yd;>
};>iJuR.:OO
5)
shZ
//------------------------------------------------------------------------------uNBhVsM6<
X0TGJ,yW(
/*********************** 7E)7sd
* 全局变量声明区 * +N_%|!F-c
***********************/ -Sgp,"a
/*kn|l 3+
struct MenuItem (*MenuPoint) = MainMenu; //结构体指针,指向结构体后由内部函数指针指向功能函数Z`t?kXDNoI vu8 DisplayStart = 0; //显⽰时的第⼀个菜单项y@JYkp>I
vu8 UrChoo = 0; //⽤户所选菜单项LdUpVO8)l
u8 DisplayPoint = 0; //显⽰指针}`FPe
u8 MaxItems; //同级最⼤菜单数giJyMd}x
vu8 ShowCount=2; //同屏显⽰菜单数}dl(9H=4
+,>bpp1
/*********************** hh}EDnx
*显⽰函数区 * zxdO3I
***********************/ |_m;@.44?U
/*e84TLU?~
void ShowMenu(void) HArYL}l
{#Qd3A
u8 n;o#6}?g.
MaxItems = MenuPoint[0].MenuCount;//定义最⼤同级菜单cf!R DisplayPoint = DisplayStart;JqZ5DjI:
for(n=0;DisplayPoint
{Pc1N~?}.
if(DisplayPoint==UrChoo)UC@ "
LCD1602_Show_Str(0,n,"->");4/|=0TC;
LCD1602_Show_Str(2,n,MenuPoint[DisplayPoint++].DisplayString);^+
mo$*KNW%\
}mNKa~E
rOT8!"
}=T]OYk
2;G_P+
l?[DO?m+R
/***********************************************************************************/bHnQLJ A>puk2 s
vxx3^;4p假如给我三天光明好词好句摘抄
/
/ KeyRunScan(); 0<9TyN6
// UpdateDisplay();wQcw#
// PtcRun();uX[
"w|
// FanRun();Ui&$/%Z|
-C+vmY*@
qT4s*kqr
e hq6.+l