Subversion Repositories group.electronics

Rev

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

Rev Author Line No. Line
161 pfowler 1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6
using WindowsInput;
7
 
8
namespace nitdcscore {
9
    public class Globals {
170 pfowler 10
 
177 pfowler 11
        public static UInt16 ADC_THRESHOLD = 15;
170 pfowler 12
        public static UInt16 ADC_DEFMAX = 950;
13
 
161 pfowler 14
        public static DcsBios bios { get; set; }
15
        public static void DcsBiosInit() {
16
            Globals.bios = new DcsBios();
17
            bios.InitUDP();
18
        }
19
 
178 pfowler 20
        public static NitvJoy vjoy { get; set; }
21
        public static void NitvJoyInit() {
22
            Globals.vjoy = new NitvJoy();
23
        }
24
 
172 pfowler 25
        //public static Dictionary<UInt16, Led> outputs = new Dictionary<UInt16, Led>();
173 pfowler 26
        public static volatile Dictionary<UInt16, UInt16> BiosOutput = new Dictionary<UInt16, UInt16>();
171 pfowler 27
 
162 pfowler 28
        public static InputSimulator SendKey = new InputSimulator();
167 pfowler 29
 
30
        public static UInt16 map_uint16(UInt16 x, UInt16 in_min, UInt16 in_max, UInt16 out_min, UInt16 out_max) {
31
            return (UInt16)((x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min);
32
        }
171 pfowler 33
 
34
        public static bool readBit(byte data, int bitNum) {
35
            return (data & (1 << bitNum)) != 0;
36
        }
37
 
173 pfowler 38
        public static void setBit(ref byte data, int bitNum) {
39
            data |= (byte)(1 << bitNum);
171 pfowler 40
        }
41
 
173 pfowler 42
        public static void clearBit(ref byte data, int bitNum) {
43
            data &= (byte)~(1 << bitNum);
171 pfowler 44
        }
181 pfowler 45
 
46
        public static bool readBit(UInt16 data, int bitNum) {
47
            return (data & (1 << bitNum)) != 0;
48
        }
49
 
50
        public static void setBit(ref UInt16 data, int bitNum) {
51
            data |= (UInt16)(1 << bitNum);
52
        }
53
 
54
        public static void clearBit(ref UInt16 data, int bitNum) {
55
            data &= (UInt16)~(1 << bitNum);
56
        }
161 pfowler 57
    }
58
}