Beispiel #1
0
        // private const int AD9833_APPLY_SIGNAL = (AD9833_BASE + 1);
        public void ApplySignal(WaveformType waveType, Registers freqReg,
                                double frequencyInHz,
                                Registers phaseReg = Registers.SAME_AS_REG0, double phaseInDeg = 0.0)
        {
            Esp32If.GpioExtent[] exts = new Esp32If.GpioExtent[] {
                new Esp32If.GpioExtent(),
                new Esp32If.GpioExtent(),
                new Esp32If.GpioExtent()
            };

            /*
             * p1=waveType
             * p2=freqReg
             ## extension ##
             ##double frequencyInHz
             ##Registers phaseReg
             ##double phaseInDeg
             */

            exts[0].Contents = esp32If.IntToBytes((int)(frequencyInHz * 10));
            exts[1].Contents = esp32If.IntToBytes((int)phaseReg);
            exts[2].Contents = esp32If.IntToBytes((int)(phaseInDeg * 1000));

            esp32If.GpioCommandExt(AD9833_APPLY_SIGNAL, (int)waveType, (int)freqReg, exts);
        }
Beispiel #2
0
        // i2c_err_t readTransmission(uint16_t address, uint8_t* buff, uint16_t size, bool sendStop = true, uint32_t* readCount = NULL);
        // private const int I2C_READ_TRANSMISSION = 608;
        public I2CError readTransmission(int address, byte[] buff, bool sendStop, out uint readCount)
        {
            Esp32If.GpioExtent[] exts = new Esp32If.GpioExtent[] {
                new Esp32If.GpioExtent(),
                new Esp32If.GpioExtent()
            };

            /*
             * p1=busNum
             * p2=address
             ## extension ##
             ##bool sendStop
             ##byte[] buff
             */

            exts[0].Contents = esp32If.IntToBytes(sendStop ? 1 : 0);
            exts[1].Contents = buff;

            byte[] rxBuf;
            var    ret = (I2CError)esp32If.GpioCommandExt(I2C_READ_TRANSMISSION, busNum, address, exts, out rxBuf);

            readCount = (uint)esp32If.BytesToInt(rxBuf);

            return(ret);
        }
Beispiel #3
0
        // uint16_t getStringWidth(const char* text, uint16_t length);

        // uint16_t getStringWidth(String text);
        // private const int OLEDDISPLAY_GET_STRING_WIDTH = (OLEDDISPLAY_BASE + 19);
        public int getStringWidth(string text)
        {
            Esp32If.GpioExtent[] exts = new Esp32If.GpioExtent[] { new Esp32If.GpioExtent() };

            /*
             * p1=0
             * p2=0
             ## extension ##
             ##char text[len]
             */

            exts[0].Contents = System.Text.Encoding.UTF8.GetBytes(text + "\0");             /* include null byte */

            return(esp32If.GpioCommandExt(OLEDDISPLAY_GET_STRING_WIDTH, 0, 0, exts));
        }
Beispiel #4
0
        // void drawFastImage(int16_t x, int16_t y, int16_t width, int16_t height, const uint8_t *image);
        // private const int OLEDDISPLAY_DRAW_FAST_IMAGE = (OLEDDISPLAY_BASE + 15);

        // void drawXbm(int16_t x, int16_t y, int16_t width, int16_t height, const uint8_t *xbm);
        // private const int OLEDDISPLAY_DRAW_XBM = 1616;

        // void drawString(int16_t x, int16_t y, String text);
        // private const int OLEDDISPLAY_DRAW_STRING = 1617;
        public void drawString(int x, int y, string text)
        {
            Esp32If.GpioExtent[] exts = new Esp32If.GpioExtent[] { new Esp32If.GpioExtent() };

            /*
             * p1=x
             * p2=y
             ## extension ##
             ##char text[len]
             */

            exts[0].Contents = System.Text.Encoding.UTF8.GetBytes(text + "\0");             /* include null byte */

            esp32If.GpioCommandExt(OLEDDISPLAY_DRAW_STRING, x, y, exts);
        }
Beispiel #5
0
        // void writePixels(const void* data, uint32_t size);//ili9341 compatible
        // private const int SPI_WRITE_PIXELS = 1219;
        public void writePixels(byte[] data)
        {
            Esp32If.GpioExtent[] exts = new Esp32If.GpioExtent[] { new Esp32If.GpioExtent() };

            /*
             * p1=spiBus
             * p2=0
             ## extension ##
             ##char buf[count]
             */

            exts[0].Contents = data;

            esp32If.GpioCommandExt(SPI_WRITE_PIXELS, (int)spiBus, 0, exts);
        }
Beispiel #6
0
        // void drawVerticalLine(int16_t x, int16_t y, int16_t length);
        // private const int OLEDDISPLAY_DRAW_VERTICAL_LINE = (OLEDDISPLAY_BASE + 13);
        public void drawVerticalLine(int x, int y, int length)
        {
            Esp32If.GpioExtent[] exts = new Esp32If.GpioExtent[] { new Esp32If.GpioExtent() };

            /*
             * p1=x
             * p2=y
             ## extension ##
             ##int length
             */

            exts[0].Contents = esp32If.IntToBytes(length);

            esp32If.GpioCommandExt(OLEDDISPLAY_DRAW_VERTICAL_LINE, x, y, exts);
        }
Beispiel #7
0
        // void fillCircle(int16_t x, int16_t y, int16_t radius);
        // private const int OLEDDISPLAY_FILL_CIRCLE = (OLEDDISPLAY_BASE + 11);
        public void fillCircle(int x, int y, int radius)
        {
            Esp32If.GpioExtent[] exts = new Esp32If.GpioExtent[] { new Esp32If.GpioExtent() };

            /*
             * p1=x
             * p2=y
             ## extension ##
             ##int radius
             */

            exts[0].Contents = esp32If.IntToBytes(radius);

            esp32If.GpioCommandExt(OLEDDISPLAY_FILL_CIRCLE, x, y, exts);
        }
Beispiel #8
0
        // void setContrast(uint8_t contrast, uint8_t precharge = 241, uint8_t comdetect = 64);
        // private const int OLEDDISPLAY_SET_CONTRAST = (OLEDDISPLAY_BASE + 26);
        public void setContrast(int contrast, int precharge = 241, int comdetect = 64)
        {
            Esp32If.GpioExtent[] exts = new Esp32If.GpioExtent[] { new Esp32If.GpioExtent() };

            /*
             * p1=contrast
             * p2=precharge
             ## extension ##
             ##int comdetect
             */

            exts[0].Contents = esp32If.IntToBytes(comdetect);

            esp32If.GpioCommandExt(OLEDDISPLAY_SET_CONTRAST, contrast, precharge, exts);
        }
Beispiel #9
0
        // size_t write(const char* s);
        // private const int OLEDDISPLAY_WRITE_STRING = (OLEDDISPLAY_BASE + 38);
        public uint write(string s)
        {
            Esp32If.GpioExtent[] exts = new Esp32If.GpioExtent[] { new Esp32If.GpioExtent() };

            /*
             * p1=0
             * p2=0
             ## extension ##
             ##char s[len]
             */

            exts[0].Contents = System.Text.Encoding.UTF8.GetBytes(s + "\0");             /* include null byte */

            return((uint)esp32If.GpioCommandExt(OLEDDISPLAY_WRITE_STRING, 0, 0, exts));
        }
Beispiel #10
0
        // void transferBits(uint32_t data, uint32_t* out, uint8_t bits);
        // private const int SPI_TRANSFER_BITS = 1214;
        public uint transferBits(uint data, int bits)
        {
            Esp32If.GpioExtent[] exts = new Esp32If.GpioExtent[] { new Esp32If.GpioExtent() };

            /*
             * p1=spiBus
             * p2=data
             ## extension ##
             ##int bits
             */

            exts[0].Contents = esp32If.IntToBytes(bits);

            return((uint)esp32If.GpioCommandExt(SPI_TRANSFER_BITS, (int)spiBus, (int)data, exts));
        }
Beispiel #11
0
        // inline size_t write(const char* s)
        // private const int I2C_WRITE_TEXT = 628;
        public uint write(string s)
        {
            Esp32If.GpioExtent[] exts = new Esp32If.GpioExtent[] { new Esp32If.GpioExtent() };

            /*
             * p1=busNum
             * p2=0
             ## extension ##
             ##char* s
             */

            exts[0].Contents = System.Text.Encoding.UTF8.GetBytes(s + "\0");             /* include null byte */

            return((uint)esp32If.GpioCommandExt(I2C_WRITE_TEXT, busNum, 0, exts));
        }
Beispiel #12
0
        // void writePattern(uint8_t* data, uint8_t size, uint32_t repeat);
        // private const int SPI_WRITE_PATTERN = 1220;
        public void writePattern(byte[] data, uint repeat)
        {
            Esp32If.GpioExtent[] exts = new Esp32If.GpioExtent[] { new Esp32If.GpioExtent() };

            /*
             * p1=spiBus
             * p2=repeat
             ## extension ##
             ##char buf[count]
             */

            exts[0].Contents = data;

            esp32If.GpioCommandExt(SPI_WRITE_PATTERN, (int)spiBus, (int)repeat, exts);
        }
Beispiel #13
0
        // uint8_t requestFrom(int address, int size);
        // private const int I2C_REQUEST_FROM = 621;
        public int requestFrom(int address, int size)
        {
            Esp32If.GpioExtent[] exts = new Esp32If.GpioExtent[] { new Esp32If.GpioExtent() };

            /*
             * p1=busNum
             * p2=address
             ## extension ##
             ##int size
             */

            exts[0].Contents = esp32If.IntToBytes(size);

            return(esp32If.GpioCommandExt(I2C_REQUEST_FROM, busNum, address, exts));
        }
Beispiel #14
0
        // size_t write(const uint8_t* buff, size_t);
        // private const int I2C_WRITE_BYTES = 623;
        public uint write(byte[] buff)
        {
            Esp32If.GpioExtent[] exts = new Esp32If.GpioExtent[] { new Esp32If.GpioExtent() };

            /*
             * p1=busNum
             * p2=0
             ## extension ##
             ##byte[] buff
             */

            exts[0].Contents = buff;

            return((uint)esp32If.GpioCommandExt(I2C_WRITE_BYTES, busNum, 0, exts));
        }
Beispiel #15
0
        // private const int OLEDDISPLAY_PRINTLN = (OLEDDISPLAY_BASE + 40);
        public void println(string text)
        {
            Esp32If.GpioExtent[] exts = new Esp32If.GpioExtent[] { new Esp32If.GpioExtent() };

            /*
             * p1=0
             * p2=0
             ## extension ##
             ##char text[len]
             */

            exts[0].Contents = System.Text.Encoding.UTF8.GetBytes(text + "\0");             /* include null byte */

            esp32If.GpioCommandExt(OLEDDISPLAY_PRINTLN, 0, 0, exts);
        }
Beispiel #16
0
        // void transferBytes(uint8_t* data, uint8_t* out, uint32_t size);
        // private const int SPI_TRANSFER_BYTES = 1213;
        public byte[] transferBytes(byte[] txBuf)
        {
            Esp32If.GpioExtent[] exts = new Esp32If.GpioExtent[] { new Esp32If.GpioExtent() };

            /*
             * p1=spiBus
             * p2=0
             ## extension ##
             ##char buf[count]
             */

            exts[0].Contents = txBuf;

            byte[] rxBuf;
            esp32If.GpioCommandExt(SPI_TRANSFER_BYTES, (int)spiBus, 0, exts, out rxBuf);

            return(rxBuf);
        }
Beispiel #17
0
        // uint8_t requestFrom(uint8_t address, uint8_t size, uint8_t sendStop);
        // private const int I2C_REQUEST_FROM8_BYTE = 618;
        public int requestFrom(byte address, int size, int sendStop)
        {
            Esp32If.GpioExtent[] exts = new Esp32If.GpioExtent[] {
                new Esp32If.GpioExtent(),
                new Esp32If.GpioExtent()
            };

            /*
             * p1=busNum
             * p2=address
             ## extension ##
             ##int size
             ##int sendStop
             */

            exts[0].Contents = esp32If.IntToBytes(size);
            exts[1].Contents = esp32If.IntToBytes(sendStop);

            return(esp32If.GpioCommandExt(I2C_REQUEST_FROM8_BYTE, busNum, address, exts));
        }
Beispiel #18
0
        // void drawCircleQuads(int16_t x0, int16_t y0, int16_t radius, uint8_t quads);
        // private const int OLEDDISPLAY_DRAW_CIRCLE_QUADS = (OLEDDISPLAY_BASE + 10);
        public void drawCircleQuads(int x0, int y0, int radius, int quads)
        {
            Esp32If.GpioExtent[] exts = new Esp32If.GpioExtent[] {
                new Esp32If.GpioExtent(),
                new Esp32If.GpioExtent()
            };

            /*
             * p1=x0
             * p2=y0
             ## extension ##
             ##int radius
             ##int quads
             */

            exts[0].Contents = esp32If.IntToBytes(radius);
            exts[1].Contents = esp32If.IntToBytes(quads);

            esp32If.GpioCommandExt(OLEDDISPLAY_DRAW_CIRCLE_QUADS, x0, y0, exts);
        }
Beispiel #19
0
        // i2c_err_t writeTransmission(uint16_t address, uint8_t* buff, uint16_t size, bool sendStop = true);
        // private const int I2C_WRITE_TRANSMISSION = 607;
        public I2CError writeTransmission(int address, byte[] buff, bool sendStop = true)
        {
            Esp32If.GpioExtent[] exts = new Esp32If.GpioExtent[] {
                new Esp32If.GpioExtent(),
                new Esp32If.GpioExtent()
            };

            /*
             * p1=busNum
             * p2=address
             ## extension ##
             ##bool sendStop
             ##byte[] buff
             */

            exts[0].Contents = esp32If.IntToBytes(sendStop ? 1 : 0);
            exts[1].Contents = buff;

            return((I2CError)esp32If.GpioCommandExt(I2C_WRITE_TRANSMISSION, busNum, address, exts));
        }
Beispiel #20
0
        // void fillRect(int16_t x, int16_t y, int16_t width, int16_t height);
        // private const int OLEDDISPLAY_FILL_RECT = (OLEDDISPLAY_BASE + 8);
        public void fillRect(int x, int y, int width, int height)
        {
            Esp32If.GpioExtent[] exts = new Esp32If.GpioExtent[] {
                new Esp32If.GpioExtent(),
                new Esp32If.GpioExtent()
            };

            /*
             * p1=x
             * p2=y
             ## extension ##
             ##int width
             ##int height
             */

            exts[0].Contents = esp32If.IntToBytes(width);
            exts[1].Contents = esp32If.IntToBytes(height);

            esp32If.GpioCommandExt(OLEDDISPLAY_FILL_RECT, x, y, exts);
        }
Beispiel #21
0
        // void drawStringMaxWidth(int16_t x, int16_t y, uint16_t maxLineWidth, String text);
        // private const int OLEDDISPLAY_DRAW_STRING_MAX_WIDTH = (OLEDDISPLAY_BASE + 18);
        public void drawStringMaxWidth(int x, int y, int maxLineWidth, string text)
        {
            Esp32If.GpioExtent[] exts = new Esp32If.GpioExtent[] {
                new Esp32If.GpioExtent(),
                new Esp32If.GpioExtent()
            };

            /*
             * p1=x
             * p2=y
             ## extension ##
             ##int maxLineWidth
             ##char text[len]
             */

            exts[0].Contents = esp32If.IntToBytes(maxLineWidth);
            exts[1].Contents = System.Text.Encoding.UTF8.GetBytes(text + "\0");             /* include null byte */

            esp32If.GpioCommandExt(OLEDDISPLAY_DRAW_STRING_MAX_WIDTH, x, y, exts);
        }
Beispiel #22
0
        // void begin(int sda = -1, int scl = -1, uint32_t frequency = 0);
        // private const int I2C_BEGIN = 600;
        public void begin(int sda = -1, int scl = -1, uint frequency = 0)
        {
            Esp32If.GpioExtent[] exts = new Esp32If.GpioExtent[] {
                new Esp32If.GpioExtent(),
                new Esp32If.GpioExtent()
            };

            /*
             * p1=busNum
             * p2=sda
             ## extension ##
             ##int scl
             ##uint frequency
             */

            exts[0].Contents = esp32If.IntToBytes(scl);
            exts[1].Contents = esp32If.IntToBytes((int)frequency);

            esp32If.GpioCommandExt(I2C_BEGIN, busNum, sda, exts);
        }
Beispiel #23
0
        // void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1);
        // private const int OLEDDISPLAY_DRAW_LINE = (OLEDDISPLAY_BASE + 6);
        public void drawLine(int x0, int y0, int x1, int y1)
        {
            Esp32If.GpioExtent[] exts = new Esp32If.GpioExtent[] {
                new Esp32If.GpioExtent(),
                new Esp32If.GpioExtent()
            };

            /*
             * p1=x0
             * p2=y0
             ## extension ##
             ##int x1
             ##int y1
             */

            exts[0].Contents = esp32If.IntToBytes(x1);
            exts[1].Contents = esp32If.IntToBytes(y1);

            esp32If.GpioCommandExt(OLEDDISPLAY_DRAW_LINE, x0, y0, exts);
        }
Beispiel #24
0
        // void beginTransaction(SPISettings settings);
        // private const int SPI_BEGIN_TRANSACTION = 1208;
        public void beginTransaction(
            uint clock = 1000000, SPIBitOrder bitOrder = SPIBitOrder.MSBFIRST, SPIMode dataMode = SPIMode.MODE0)
        {
            Esp32If.GpioExtent[] exts = new Esp32If.GpioExtent[] {
                new Esp32If.GpioExtent(),
                new Esp32If.GpioExtent()
            };

            /*
             * p1=spiBus
             * p2=clock
             ## extension ##
             ##int bitOrder
             ##int dataMode
             */

            exts[0].Contents = esp32If.IntToBytes((int)bitOrder);
            exts[1].Contents = esp32If.IntToBytes((int)dataMode);

            esp32If.GpioCommandExt(SPI_BEGIN_TRANSACTION, (int)spiBus, (int)clock, exts);
        }
Beispiel #25
0
        // void drawProgressBar(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t progress);
        // private const int OLEDDISPLAY_DRAW_PROGRESS_BAR = (OLEDDISPLAY_BASE + 14);
        public void drawProgressBar(int x, int y, int width, int height, int progress)
        {
            Esp32If.GpioExtent[] exts = new Esp32If.GpioExtent[] {
                new Esp32If.GpioExtent(),
                new Esp32If.GpioExtent(),
                new Esp32If.GpioExtent()
            };

            /*
             * p1=x
             * p2=y
             ## extension ##
             ##int width
             ##int height
             ##int progress
             */

            exts[0].Contents = esp32If.IntToBytes(width);
            exts[1].Contents = esp32If.IntToBytes(height);
            exts[2].Contents = esp32If.IntToBytes(progress);

            esp32If.GpioCommandExt(OLEDDISPLAY_DRAW_PROGRESS_BAR, x, y, exts);
        }
Beispiel #26
0
        // void begin(int8_t sck = -1, int8_t miso = -1, int8_t mosi = -1, int8_t ss = -1);
        // private const int SPI_BEGIN = 1200;
        public void begin(int sck = -1, int miso = -1, int mosi = -1, int ss = -1)
        {
            Esp32If.GpioExtent[] exts = new Esp32If.GpioExtent[] {
                new Esp32If.GpioExtent(),
                new Esp32If.GpioExtent(),
                new Esp32If.GpioExtent()
            };

            /*
             * p1=spiBus
             * p2=sck
             ## extension ##
             ##int miso
             ##int mosi
             ##int ss
             */

            exts[0].Contents = esp32If.IntToBytes(miso);
            exts[1].Contents = esp32If.IntToBytes(mosi);
            exts[2].Contents = esp32If.IntToBytes(ss);

            esp32If.GpioCommandExt(SPI_BEGIN, (int)spiBus, sck, exts);
        }