test_1.c
来自「一个基于C51开发的计价秤」· C语言 代码 · 共 39 行
C
39 行
#include <reg52.h>
#include <stdio.h>
#include <math.h>
#define PI 3.1415926
#define Local_Latitude 0
#define Local_Height 0.0
#define Destination_Latitude 90
#define Destination_Height 1000
float Weight_Calibrated(float temp_Weight)
{
float g1,g2,x,y;
x=Local_Latitude/180.0;
y=Destination_Latitude/180.0;
x=x*3.1415926;
y=y*3.1415926;
g1=9.780318*(1+0.005324*(sin(x)*sin(x))-0.0000059*(sin(2*x)*sin(2*x)))+(-0.3086*0.00005*Local_Height);
g2=9.780318*(1+0.005324*(sin(y)*sin(y))-0.0000059*(sin(2*y)*sin(2*y)))+(-0.3086*0.00005*Destination_Height);
return temp_Weight*(g2/g1);
}
#ifdef MONITOR51 /* Debugging with Monitor-51 needs */
char code reserve [3] _at_ 0x23; /* space for serial interrupt if */
#endif
main()
{
float weight1=0,weight2=19.99;
#ifndef MONITOR51
SCON = 0x50; /* SCON: mode 1, 8-bit UART, enable rcvr */
TMOD |= 0x20; /* TMOD: timer 1, mode 2, 8-bit reload */
TH1 = 221; /* TH1: reload value for 1200 baud @ 16MHz */
TR1 = 1; /* TR1: timer 1 run */
TI = 1; /* TI: set TI to send first char of UART */
#endif
weight1=Weight_Calibrated(weight2);
while(1);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?