Subversion Repositories group.electronics

Rev

Rev 173 | Rev 178 | Go to most recent revision | 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
 
172 pfowler 20
        //public static Dictionary<UInt16, Led> outputs = new Dictionary<UInt16, Led>();
173 pfowler 21
        public static volatile Dictionary<UInt16, UInt16> BiosOutput = new Dictionary<UInt16, UInt16>();
171 pfowler 22
 
162 pfowler 23
        public static InputSimulator SendKey = new InputSimulator();
167 pfowler 24
 
25
        public static UInt16 map_uint16(UInt16 x, UInt16 in_min, UInt16 in_max, UInt16 out_min, UInt16 out_max) {
26
            return (UInt16)((x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min);
27
        }
171 pfowler 28
 
29
        public static bool readBit(byte data, int bitNum) {
30
            return (data & (1 << bitNum)) != 0;
31
        }
32
 
173 pfowler 33
        public static void setBit(ref byte data, int bitNum) {
34
            data |= (byte)(1 << bitNum);
171 pfowler 35
        }
36
 
173 pfowler 37
        public static void clearBit(ref byte data, int bitNum) {
38
            data &= (byte)~(1 << bitNum);
171 pfowler 39
        }
161 pfowler 40
    }
41
}