R. Scott Coppersmith
Published © GPL3+

The Ultimate Personal Magic Machine

The Ultimate Personal Magic Machine.

AdvancedWork in progress942
The Ultimate Personal Magic Machine

Things used in this project

Hardware components

Hexiwear
NXP Hexiwear
×1

Story

Read more

Schematics

Hexiwear schematics

HexiWear schematics

Code

Main.cpp

C/C++
main.cpp mbed code
#include "mbed.h"
#include <SSD1351_SPI.h>
#include <Hexi_Magic.h>
 
//SSD1351_SPI ( mosi, miso, sclk, cs, dc ) ;  
SSD1351_SPI OLED96x96(PTB22,PTB23,PTB21,PTB20,PTD15); 
// Pin connections for Hexiwear
DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);
DigitalOut BOOSTEN(PTC13);  //oled power enable
int count = 0;

extern const uint8_t Main_screen_bmp[ 36864 ];
extern const uint8_t smile_bmp[ 36864 ];
extern const uint8_t money_bmp[ 36864 ];
extern const uint8_t brain_bmp[ 36864 ];
int argb = 0xff000000; 
int rgbd = 0x00000000;
int xposg = 0;
int yposg = 0;
void displaybmp(const uint8_t bmpfile[ 36864 ]) {
    count = 0;
    for(int xpos=0;xpos<97;xpos++)
    {
        for(int ypos=0;ypos<96;ypos++)
        {
            rgbd = ((bmpfile[count+3]<<24)|(bmpfile[count]<<16)|(bmpfile[count+1]<<8)|(bmpfile[count+2]));
            OLED96x96.drawPixel(ypos+20,xpos,rgbd);   
            count=count+4; 
        }
    }
}
int main() {
    led1 = 1;
    led2 = 1;
    led3 = 1;
    BOOSTEN = 1;
    OLED96x96.open();
    OLED96x96.state(Display::DISPLAY_ON);
    OLED96x96.fillRect(16,0,111,96,0xff000000);//alpha, BGR
    while (1) 
    {
        displaybmp(Main_screen_bmp);
        Thread::wait(2000);
        displaybmp(smile_bmp); 
        Thread::wait(2000);
        displaybmp(brain_bmp);
        Thread::wait(2000);
        displaybmp(money_bmp);
        Thread::wait(2000);  
    }

}

Hexi_Magic

C/C++
Hexi_Magic.bin
No preview (download only).

HexiWear OLED Bitmap Tool

C#
HexiWear OLED Bitmap Tool
using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplicationOLED96x96
{
    public partial class Form1 : Form
    {
        String filename1 = string.Empty;
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            String input = string.Empty;
            String tb = string.Empty;
            textBox1.AppendText("Loading Bitmap Image" + Environment.NewLine);
            //pictureBox1.LoadAsync("c:\\image.bmp");
            OpenFileDialog fd = new OpenFileDialog();
            fd.Filter = "bmp files (*.bmp)|*.bmp|All files (*.*)|*.*";
            fd.Title = "Select an image file";
            if (fd.ShowDialog() == DialogResult.OK)
                pictureBox1.LoadAsync(fd.FileName);
            filename1 = fd.FileName;
            textBox1.AppendText("Done" + Environment.NewLine);
            //Save image from PictureBox into MemoryStream object.
            MemoryStream ms = new MemoryStream();
            pictureBox1.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
            //Read from MemoryStream into Byte array.
            Byte[] bytBLOBData = new Byte[ms.Length];
            ms.Position = 0;
            ms.Read(bytBLOBData, 0, Convert.ToInt32(ms.Length));
            string s2 = BitConverter.ToString(bytBLOBData);
            //textBox1.AppendText(s2);
            tb = ms.Length.ToString();
            textBox1.AppendText(" Stream Length(bytes): " + tb + Environment.NewLine);
            tb = pictureBox1.Image.PixelFormat.ToString();
            textBox1.AppendText("  PixelFormat: " + tb + Environment.NewLine);
            button3.Enabled = true;
            toolStripButton2.Enabled = true;
        }

HexiWear OLED Bitmap Tool

HexiWear OLED Bitmap Tool

Credits

R. Scott Coppersmith

R. Scott Coppersmith

15 projects • 24 followers
Research Engineer, Embedded systems designer

Comments