kn62a.nas 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # KN-62a DME Support
  2. #
  3. # Gary Neely aka 'Buckaroo'
  4. #
  5. # Round-off errors screw-up the textranslate animation used to display decimal place digits.
  6. # This matters especially for frequencies where decimals must be accurate.
  7. # I get around the problem by using a listener to split a freq into MHz and KHz components
  8. # and copy these to a separate integer values used by the animations.
  9. var dme_sel = props.globals.getNode("/instrumentation/dme/frequencies/selected-mhz");
  10. var dme_selmhz = props.globals.getNode("/instrumentation/dme/frequencies/display-sel-mhz");
  11. var dme_selkhz = props.globals.getNode("/instrumentation/dme/frequencies/display-sel-khz");
  12. # Update MHz and KHz sub-strings on freq changes
  13. setlistener(dme_sel, func {
  14. var dmestr = sprintf("%.2f",dme_sel.getValue()); # String conversion
  15. var dmetemp = split(".",dmestr); # Get sub-strings
  16. dme_selmhz.setValue(dmetemp[0]);
  17. dme_selkhz.setValue(dmetemp[1]);
  18. });
  19. var dme_mode = props.globals.getNode("/controls/switches/kn-62a-mode");
  20. var dme_src = props.globals.getNode("/instrumentation/dme/frequencies/source");
  21. # On mode changes, change frequency source:
  22. # mode 0 (RMT): NAV1
  23. # mode 1 (Freq): DME internal
  24. # mode 2 (GS/T): DME internal
  25. setlistener(dme_mode, func {
  26. var mode = dme_mode.getValue();
  27. var source = "dme";
  28. if (mode == 0) {
  29. source = "nav[0]";
  30. }
  31. dme_src.setValue("/instrumentation/"~source~"/frequencies/selected-mhz");
  32. });