OLED Emulator - Faster vertical bytes

Size
6,075 Kb
Views
6,072

How do I make an oled emulator - faster vertical bytes?

This is a monochrome OLED emulator.It emulates the OLED video RAM, but not the OLED modules timings.It's great for helping with the development of bit and byte manipulation algorithms that produce graphics like lines, circles, bitmaps, scrolling.. What is a oled emulator - faster vertical bytes? How do you make a oled emulator - faster vertical bytes? This script and codes were developed by Sarah Cartwright on 05 December 2022, Monday.

OLED Emulator - Faster vertical bytes Previews

OLED Emulator - Faster vertical bytes - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>OLED Emulator - Faster vertical bytes</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div id="centerer"> <div id="OLEDPCB"> <div id="display"> <canvas id="OLED"></canvas><br /> <div id="textOutput"></div> </div> </div>
</div> <script src="js/index.js"></script>
</body>
</html>

OLED Emulator - Faster vertical bytes - Script Codes CSS Codes

body { padding: 0px; margin: 0px; background: #2e2e2e; color: #909090; font: 20px arial, sans-serif;
}
#OLEDPCB{ width: 750px; height: 770px; background-repeat: no-repeat; background-size: 100%; background-image: url(http://untamed.co.uk/miscImages/oled_display.png);
}
#OLED{ margin-top: 175px; margin-left: 10px; abackground: #000; aborder: 2px solid gray;
}
#textOutput{ margin-top: 6px; font-size: 17px;
}
#display { text-align: center; width: 750px; height: 770px; abackground: green;
}
#centerer {	bottom: 0;	left: 0;	margin: auto;	position: absolute;	right: 0;	top: 0; width: 750px; height: 720px;
}

OLED Emulator - Faster vertical bytes - Script Codes JS Codes

/*
A simple monochrome OLED memory/display simulator for mapping byte bits to individual pixels.
With it you can test your algorithms for masked sprites, pixel manipulation routines, line drawing routines and circle drawing.
All using a monochrome 1 byte-per-8-pixels fast response OLED screen.
The memory is contained in OLEDScreen[], the length of the array is found by the program by ((Width in OLED pixels / 8) + Height in OLED pixels).
It is calculated automatically, and can be found by OLEDScreen.length.
The RAM update is VSynced.
function loop(){} is called 60 times a second (configurable), in which you should manipulate OLEDScreen[], once loop(){} exits, the OLED display will then update.
Make sure loop(){} isn't running for more than a few milliseconds to keep the animation at 60 FPS.
*/
//Configuration
var FPS = 20; // Speed OLED is refreshed.
var OLED_Red = 90, OLED_Green = 120, OLED_Blue = 180 // Colour of the illuminated OLED pixels.
var OLEDWidth = 128; // In pixels, must be multiples of 8. (1 byte per 8 pixels)
var OLEDHeight = 64; // In pixels.
//Your program goes here:
var counter = 0; // not used while debugging
var state = 1; // not used while debugging
var stateCounter = 0; // not used while debugging
var xx=0, yy=0; // not used while debugging
var index=0; // debugging counter for next byte to fill in.
function loop(){ var dl = OLEDScreen.length; OLEDScreen[30] = 255; // Should be an 8 pixel vertical line. 30 pixels from the left, at the top. It's only 4 pixels! OLEDScreen[31 + 128] = 1 + 127; // Should be 2 vertical pixels with a gap between 31 pixels across, 9 pixels from the top). The two outside pixels are in the middle. OLEDScreen[32 + 128 + 128] = 255;// Should be an 8 pixel vertical line. 32 pixels from the left, 17 pixels from the top. Looks right (but the pixel order is wrong!) //This slowly draws a bar of 8 pixels high, from the top left across the screen, //then continuing on underneath those. //It doesn't! It's only 4 pixels high on the first horizontal bar.....? OLEDScreen[index] = 255; if(++index==dl) { xx=0; for(var c=0;c<dl;c++) OLEDScreen[c] = 0; }
}
function notUsedInDebugging(){ //stateCounter++; if(state==0){ //for(var ctr = 0;ctr < 50;ctr++) //setPixel(rand(0, OLEDWidth), rand(0, OLEDHeight)); if(stateCounter == 5000){ stateCounter=0; state++; } } //Phase 1: Draw vertical bands if(state==1){ for(var i = 0; i < dl; i++) OLEDScreen[i] = counter; if(++counter == 256){ counter = 0; stateCounter=0; state++; } } if(state==2){ for(var i = 0; i < dl; i++) OLEDScreen[i] = logo1_bytes[i]; if(stateCounter == 300){ stateCounter=0; state++; } } if(state==3){ for(var i = 0; i < dl; i++) OLEDScreen[i] = logo2_bytes[i]; if(stateCounter == 300){ stateCounter=0; state = 1; } }
}
var WHITE = 1, BLACK = 2, INVERSE = 3;
var pixelColor = WHITE;
function setPixel(x, y){ if (x >= 0 && x < OLEDWidth && y >= 0 && y < OLEDHeight) { debugger; switch (pixelColor) { case WHITE: OLEDScreen[x + (y / 8) * OLEDWidth] |= (1 << (y & 7)); break; case BLACK: OLEDScreen[x + (y / 8) * OLEDWidth] &= ~(1 << (y & 7)); break; case INVERSE: OLEDScreen[x + (y / 8) * OLEDWidth] ^= (1 << (y & 7)); break; } }
}
// http://www.online-utility.org/image_converter.jsp XBM file format (text), with {} swapped with [].
var logo1_bytes = [ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x83, 0x2E, 0xEC, 0x82, 0xEF, 0x1B, 0xC3, 0xAE, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xEF, 0xAC, 0xEB, 0xEE, 0xCF, 0xE9, 0xBA, 0xAE, 0xF7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xEF, 0xAC, 0xEB, 0xEE, 0xCF, 0xE9, 0xBA, 0xAE, 0xF7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xEF, 0xAA, 0xEB, 0xEE, 0xAF, 0xEA, 0xBA, 0xAE, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xEF, 0x26, 0xEC, 0xEE, 0xAF, 0xEA, 0xBA, 0xAE, 0xF7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xEF, 0xA6, 0xEF, 0xEE, 0xAF, 0xEA, 0xBA, 0xAE, 0xF7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x83, 0xAE, 0x1F, 0xEF, 0x6F, 0x1B, 0xC3, 0x31, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x03, 0x0F, 0x60, 0x80, 0x3F, 0x00, 0x00, 0x80, 0xC1, 0x07, 0x00, 0x00, 0x00, 0x00, 0x06, 0xE0, 0x87, 0x1F, 0x78, 0x80, 0x3F, 0x00, 0x00, 0x80, 0xE1, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x06, 0x70, 0xCE, 0x39, 0x7E, 0x00, 0x38, 0x00, 0x00, 0x80, 0x31, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x06, 0x70, 0xCE, 0x39, 0x7E, 0x00, 0x38, 0x00, 0x00, 0x80, 0x31, 0x98, 0x1D, 0x38, 0x70, 0xE0, 0x06, 0x70, 0xCE, 0x39, 0x70, 0x00, 0x38, 0x02, 0x40, 0x80, 0xF1, 0x80, 0x3F, 0x7C, 0xF8, 0xF0, 0x07, 0x70, 0x0E, 0x38, 0x70, 0x00, 0x18, 0x02, 0x40, 0x80, 0xE1, 0x87, 0x73, 0xC6, 0x8C, 0x39, 0x07, 0x70, 0x0E, 0x1C, 0x70, 0x00, 0x1C, 0x52, 0x4F, 0x83, 0x81, 0x8F, 0x61, 0xFE, 0xFC, 0x19, 0x06, 0x70, 0x0E, 0x1E, 0x70, 0x00, 0x1C, 0xCA, 0xD2, 0x84, 0x01, 0x9C, 0x61, 0xFE, 0xFC, 0x19, 0x06, 0x70, 0x0E, 0x0E, 0x70, 0x00, 0x1C, 0x46, 0x52, 0x84, 0x31, 0x98, 0x61, 0x06, 0x0C, 0x18, 0x06, 0x70, 0x0E, 0x0F, 0x70, 0x00, 0x0E, 0x4A, 0x52, 0x84, 0x71, 0x9C, 0x73, 0xCE, 0x9C, 0x39, 0x07, 0x70, 0x0E, 0x07, 0x70, 0x00, 0x0E, 0x4A, 0x52, 0x84, 0xE1, 0x8F, 0x3F, 0x7C, 0xF8, 0xF0, 0x07, 0x70, 0x8E, 0x03, 0x70, 0x00, 0x0E, 0x52, 0x52, 0x84, 0xC1, 0x87, 0x1D, 0x38, 0x70, 0xE0, 0x06, 0x70, 0x8E, 0x03, 0x70, 0x0E, 0x0E, 0x00, 0x00, 0x80, 0x01, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xC7, 0x3F, 0x70, 0x0E, 0x07, 0x00, 0x00, 0x80, 0x01, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC3, 0x3F, 0x70, 0x0E, 0x07, 0x00, 0x00, 0x80, 0x01, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x3C, 0x80, 0xC1, 0x83, 0x0F, 0x00, 0x00, 0x80, 0xF1, 0x0F, 0x7F, 0x38, 0x38, 0x00, 0x80, 0x1F, 0x7E, 0xE0, 0xE1, 0xC7, 0x1F, 0x00, 0x00, 0x80, 0xF1, 0x1F, 0xFF, 0x38, 0x38, 0x00, 0xC0, 0x39, 0xE7, 0xF8, 0x71, 0xCE, 0x39, 0x00, 0x00, 0x80, 0x31, 0x38, 0xC3, 0x79, 0x3C, 0x00, 0xC0, 0x39, 0xE7, 0xF8, 0x71, 0xCE, 0x39, 0x00, 0x00, 0x80, 0x31, 0x30, 0x83, 0x79, 0x3C, 0x00, 0xC0, 0x39, 0x07, 0xC0, 0x71, 0xCE, 0x39, 0x00, 0x00, 0x80, 0x31, 0x38, 0xC3, 0x59, 0x34, 0x00, 0xC0, 0x39, 0x7F, 0xC0, 0x71, 0x0E, 0x38, 0x00, 0x00, 0x80, 0xF1, 0x1F, 0xFF, 0xD8, 0x36, 0x00, 0xC0, 0x39, 0xFF, 0xC0, 0x71, 0x0E, 0x1F, 0xAA, 0xE9, 0x81, 0xF1, 0x07, 0x7F, 0xD8, 0x36, 0x00, 0xC0, 0x39, 0xE7, 0xC0, 0x71, 0x0E, 0x3F, 0x66, 0x5A, 0x82, 0x31, 0x0E, 0x03, 0xD8, 0x36, 0x00, 0xC0, 0x39, 0xE7, 0xC0, 0x71, 0x0E, 0x38, 0x22, 0x4A, 0x82, 0x31, 0x1C, 0x03, 0x98, 0x33, 0x00, 0xC0, 0x39, 0xE7, 0xC0, 0x71, 0xCE, 0x39, 0x22, 0x4A, 0x82, 0x31, 0x18, 0x03, 0x98, 0x33, 0x00, 0xC0, 0x39, 0xE7, 0xC0, 0x71, 0xCE, 0x39, 0x62, 0x4A, 0x82, 0x31, 0x38, 0x03, 0x98, 0x33, 0x00, 0xC0, 0x39, 0xE7, 0xC0, 0x71, 0xCE, 0x39, 0xA2, 0x49, 0x82, 0x31, 0x70, 0x03, 0x18, 0x31, 0x00, 0xC0, 0x39, 0xE7, 0xC0, 0x71, 0xCE, 0x39, 0x20, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x1F, 0x7E, 0xC0, 0xE1, 0x87, 0x1F, 0x20, 0x00, 0x80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 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ];
//------------------------------------------------------------
//Start of emulator.
//Actual FPS acheived.
var actualFPS = 0, actualFPSold = 0;
window.requestAnimFrame=function(){return window.requestAnimationFrame|| window.webkitRequestAnimationFrame|| window.mozRequestAnimationFrame|| window.oRequestAnimationFrame|| window.msRequestAnimationFrame|| function(a){window.setTimeout(a, 1E3 / 60)}}();
setInterval(updateFPSold, 1000);
document.onselectstart = function() { return false;
};
//OLED display RAM.
var OLEDScreenRaw = new ArrayBuffer(Math.round(OLEDWidth / 8) * OLEDHeight);
var OLEDScreen = new Uint8ClampedArray(OLEDScreenRaw);
//Canvas display
var c = document.getElementById("OLED");
var ctx = c.getContext('2d');
var divId = document.getElementById("textOutput");
var OLEDPCBStyle = document.getElementById("OLEDPCB").style;
var displayStyle = document.getElementById("display").style;
var cStyle = c.style;
var imageData = ctx.getImageData(0, 0, OLEDWidth, OLEDHeight);
var buf = new ArrayBuffer(imageData.data.length);
var buf8 = new Uint8ClampedArray(buf);
var buf32 = new Uint32Array(buf);
//Scale the panels pixels by 4 times, and make them square shaped, not interpolated.
cStyle.cssText = 'image-rendering: pixelated;';
cStyle.width = OLEDWidth * 4 + "px";
cStyle.height = OLEDHeight * 4 + "px";
ctx.imageSmoothingEnabled = false;
//OLEDPCBStyle.width = cStyle.width;
//OLEDPCBStyle.height = cStyle.height;
c.width = OLEDWidth;
c.height = OLEDHeight;
var centerX= Math.round(OLEDWidth / 2);
var centerY= Math.round(OLEDHeight / 2);
var oldTimeStamp = 0;
function updateFPSold(){ actualFPSold = actualFPS; actualFPS = 0;
}
function newFrame(currentTimeStamp) { setTimeout(function() {	requestAnimFrame(newFrame);	}, 1000 / FPS); var timeDelta = currentTimeStamp - oldTimeStamp; oldTimeStamp = currentTimeStamp; divId.innerHTML = actualFPSold + " FPS - " + Math.round(timeDelta) + " milliseconds"; loop(); drawBufferAlternateMemoryLayout(); //drawBuffer(); actualFPS += 1;
}
function drawBuffer(){ var dl = OLEDScreen.length; var buf8I = -1; for (var i = 0; i < dl; i++) { var pixelByte = OLEDScreen[i]; buf8I+=4; buf8[buf8I] = (pixelByte & 1)?200:0; buf8I+=4; buf8[buf8I] = (pixelByte & 2)?200:0; buf8I+=4; buf8[buf8I] = (pixelByte & 4)?200:0; buf8I+=4; buf8[buf8I] = (pixelByte & 8)?200:0; buf8I+=4; buf8[buf8I] = (pixelByte & 16)?200:0; buf8I+=4; buf8[buf8I] = (pixelByte & 32)?200:0; buf8I+=4; buf8[buf8I] = (pixelByte & 64)?200:0; buf8I+=4; buf8[buf8I] = (pixelByte & 128)?200:0; } imageData.data.set(buf8); ctx.putImageData(imageData, 0, 0);
}
//This draws each byte vertically on the display starting at the top left.
function drawBufferAlternateMemoryLayout(){ var dl = OLEDScreen.length; var buf8I = -1; for(var zz=0; zz < dl; zz++){ var YOffset = Math.round(zz / OLEDWidth / 8) * OLEDWidth; var pixelMask = 1 << ((zz / OLEDWidth) % 8); var XYOffset = (zz % OLEDWidth) + YOffset; buf8I+=4; buf8[buf8I] = (OLEDScreen[XYOffset] & pixelMask)?200:0; buf8I+=4; buf8[buf8I] = (OLEDScreen[XYOffset + 1] & pixelMask)?200:0; buf8I+=4; buf8[buf8I] = (OLEDScreen[XYOffset + 2] & pixelMask)?200:0; buf8I+=4; buf8[buf8I] = (OLEDScreen[XYOffset + 3] & pixelMask)?200:0; buf8I+=4; buf8[buf8I] = (OLEDScreen[XYOffset + 4] & pixelMask)?200:0; buf8I+=4; buf8[buf8I] = (OLEDScreen[XYOffset + 5] & pixelMask)?200:0; buf8I+=4; buf8[buf8I] = (OLEDScreen[XYOffset + 6] & pixelMask)?200:0; buf8I+=4; buf8[buf8I] = (OLEDScreen[XYOffset + 7] & pixelMask)?200:0; } imageData.data.set(buf8); ctx.putImageData(imageData, 0, 0);
}
function clearBuffer(){ var dl = buf32.length; var a=0; var value = (a << 24) | // alpha (OLED_Blue << 16) | // blue (OLED_Green<< 8) | // green OLED_Red; // red for (var i = 0; i < dl; i++) buf32[i] = value; imageData.data.set(buf8); ctx.putImageData(imageData, 0, 0);
}
function rand(rMi, rMa){return ~~((Math.random()*(rMa-rMi+1))+rMi);}
clearBuffer();
newFrame();
OLED Emulator - Faster vertical bytes - Script Codes
OLED Emulator - Faster vertical bytes - Script Codes
Home Page Home
Developer Sarah Cartwright
Username SarahC
Uploaded December 05, 2022
Rating 3
Size 6,075 Kb
Views 6,072
Do you need developer help for OLED Emulator - Faster vertical bytes?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Sarah Cartwright (SarahC) Script Codes
Create amazing love letters with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!