fnd_screen_func.nas 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # define some helper functions
  2. # for the FND screen
  3. # ============================
  4. var ROSESC = 0.58;
  5. var ROSEX = 180;
  6. var ROSEY = ROSEX * ROSESC;
  7. var DMEFACTOR = 0.0005399;
  8. var ALTFACTOR = (651-464)/400;
  9. var FPS2FPM = 60;
  10. var SHIFT_THRES = 0.5;
  11. var ROT_THRES = 0.1;
  12. var rose_mark_x = func (w) math.sin((w*10 - adc.heading.get())*D2R)*ROSEX;
  13. var rose_mark_y = func (w) -math.cos((w*10 - adc.heading.get())*D2R)*ROSEY;
  14. var DME_format = func (p) { x = (getprop(p) or 0) * DMEFACTOR; return sprintf((x>10) ? "%3.0f NM" : "%4.1f NM", x); };
  15. var altTs = func (n) {
  16. var a = (adc.alt.get() or 0) + n*100;
  17. var x = int(a/1000);
  18. if (a<0 and x==0) return "-0";
  19. return ""~x;
  20. };
  21. var altHs = func (n) {
  22. var a = (adc.alt.get() or 0) + n*100;
  23. var x = abs( math.floor(math.fmod(a,1000)/100) );
  24. if (x==0) return "000";
  25. if (x==5) return "500";
  26. return "" ~ x;
  27. };
  28. var altMove = func (n) {
  29. var a=adc.alt.get() + n*100;
  30. var x = int(a/1000);
  31. if (a<0 and x==0) return 7;
  32. return (x < 0 or x > 9) ? 12 : 1;
  33. };