Subversion Repositories group.electronics

Rev

Rev 178 | Blame | Compare with Previous | Last modification | View Log | RSS feed

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WindowsInput;

namespace nitdcscore {
    public class Globals {

        public static UInt16 ADC_THRESHOLD = 15;
        public static UInt16 ADC_DEFMAX = 950;

        public static DcsBios bios { get; set; }
        public static void DcsBiosInit() {
            Globals.bios = new DcsBios();
            bios.InitUDP();
        }

        public static NitvJoy vjoy { get; set; }
        public static void NitvJoyInit() {
            Globals.vjoy = new NitvJoy();
        }

        //public static Dictionary<UInt16, Led> outputs = new Dictionary<UInt16, Led>();
        public static volatile Dictionary<UInt16, UInt16> BiosOutput = new Dictionary<UInt16, UInt16>();

        public static InputSimulator SendKey = new InputSimulator();

        public static UInt16 map_uint16(UInt16 x, UInt16 in_min, UInt16 in_max, UInt16 out_min, UInt16 out_max) {
            return (UInt16)((x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min);
        }

        public static bool readBit(byte data, int bitNum) {
            return (data & (1 << bitNum)) != 0;
        }

        public static void setBit(ref byte data, int bitNum) {
            data |= (byte)(1 << bitNum);
        }

        public static void clearBit(ref byte data, int bitNum) {
            data &= (byte)~(1 << bitNum);
        }

        public static bool readBit(UInt16 data, int bitNum) {
            return (data & (1 << bitNum)) != 0;
        }

        public static void setBit(ref UInt16 data, int bitNum) {
            data |= (UInt16)(1 << bitNum);
        }

        public static void clearBit(ref UInt16 data, int bitNum) {
            data &= (UInt16)~(1 << bitNum);
        }
    }
}