微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 1602控制forMSP430

1602控制forMSP430

时间:11-27 来源:互联网 点击:

  1. WriteData(a[i]);
  2. }
  3. /*************************************************************************
  4. //名称:WriteNum
  5. //参数:待写入数字,unsignedcharx,unsignedchary
  6. //返回值:无
  7. //功能:在给定位置显示一个数字(不超过5位且小于65536)
  8. *************************************************************************/
  9. voidWriteNum(uintn,ucharx,uchary)
  10. {
  11. ucharfive,four,three,two,one;
  12. LocateXY(x,y);
  13. if((n>=10000)&&(n<=65535))
  14. {
  15. five=n/10000;
  16. four=(n%10000)/1000;
  17. three=((n-five*10000)%1000)/100;
  18. two=((n-five*10000)%1000-three*100)/10;
  19. one=((n-five*10000)%1000-three*100)%10;
  20. WriteData(NUM[five]);
  21. WriteData(NUM[four]);
  22. WriteData(NUM[three]);
  23. WriteData(NUM[two]);
  24. WriteData(NUM[one]);
  25. }
  26. if((n>=1000)&&(n<=9999))
  27. {
  28. four=n/1000;
  29. three=(n%1000)/100;
  30. two=(n%1000-three*100)/10;
  31. one=(n%1000-three*100)%10;
  32. WriteData(NUM[four]);
  33. WriteData(NUM[three]);
  34. WriteData(NUM[two]);
  35. WriteData(NUM[one]);
  36. }
  37. if((n>=100)&&(n<=999))
  38. {
  39. three=n/100;
  40. two=(n-three*100)/10;
  41. one=(n-three*100)%10;
  42. WriteData(NUM[three]);
  43. WriteData(NUM[two]);
  44. WriteData(NUM[one]);
  45. }
  46. if((n>=10)&&(n<=99))
  47. {
  48. two=n/10;
  49. one=n%10;
  50. WriteData(NUM[two]);
  51. WriteData(NUM[one]);
  52. }
  53. if((n>0)&&(n<=9))WriteData(NUM[n]);
  54. }
  55. /*************************************************************************
  56. //名称:WriteFloat
  57. //参数:待写入浮点数,unsignedcharx,unsignedchary
  58. //返回值:无
  59. //功能:在给定位置显示一个浮点数(整数部分和小数部分都不超过两位)
  60. *************************************************************************/
  61. voidWriteFloat(floatn,ucharx,uchary)
  62. {
  63. uintInteger,Decimal;//Integer用于存放整数部分,Decimal用于存放小数部分
  64. Integer=(uint)(n/1);
  65. Decimal=(uint)(n*100-Integer*100);
  66. WriteNum(Integer,x,y);
  67. WriteData(NUM[10]);
  68. WriteNum(Decimal,x+3,y);
  69. }


Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top