A web application for generating character or image byte arrays for dot matrix style OLED or LCD displays.
- Visual Dot Matrix Editor: Draw and erase pixels with mouse clicks
- Multiple Byte Order Support: Row major, column major, and column+row hybrid byte ordering
- Endianness Selection: Support for both big-endian and little-endian output
- Dynamic Size Adjustment: Support for any size from 1×1 to 128×128 pixels
- C Code Generation: Automatically generate ready-to-use C language byte array code
- Dual Font System Support:
- Built-in Bitmap Fonts: 7×6 and 12×8 pixel perfectly optimized fonts, designed specifically for dot matrix displays
- System Font Rendering: Support for system font rendering (future feature)
- Intelligent Text Rendering Engine:
- Multi-language Character Support: Complete English letters, numbers, and common symbols library
- Character Spacing Optimization: Automatic character spacing adjustment for optimal display
- Multi-line Text Processing: Support for line breaks with automatic multi-line text layout
- Advanced Typography Features:
- Three Alignment Modes: Left, center, and right alignment
- Precise Position Control: Pixel-level X/Y coordinate positioning
- Smart Content Merging: Option to merge with existing content or completely replace
- Real-time Preview System:
- Instant Preview: Real-time display of rendering effects during text input
- Position Preview: Visual display of exact text position in grid
- Merge Effect Preview: Preview of merging effects with existing content
- Project Save/Load: Support for saving and loading project files in JSON format
- Code Import: Reverse import from existing C byte array code to editor
- Multi-format Export: Support for exporting JSON project files and C code files
- Real-time Preview: Real-time preview functionality during text input
- Bilingual Support: Complete Chinese and English interface switching
- Responsive Design: Adapts to different screen sizes
- Intuitive Operation: Left click to draw, right click (or Ctrl+Left) to erase
- Real-time Feedback: Display current grid size, byte order, and other information
- HTML5: Modern web standards with semantic tags
- CSS3: Responsive layout with Bootstrap 4 framework
- JavaScript (ES5): Core logic implementation with jQuery library support
- Web Fonts: Google Fonts (Roboto Mono)
// Core data structures
var matrix; // 2D array storing pixel data
var rowMajor; // Byte order control
var msbendian; // Endianness control
var columnPlusRow; // Column+row hybrid mode
var FontManager = {
fonts: {}, // Font cache
loadFont: function(), // Font loading
getCharacterData: function() // Character data retrieval
};
var TextRenderer = {
renderCharacter: function(), // Single character rendering
renderText: function(), // Text rendering
generatePreview: function() // Preview generation
};
var LANGUAGE = {
'en': { /* English translations */ },
'zh': { /* Chinese translations */ }
};
const FONT_DATA = {
"7x6": { /* 7×6 pixel font data */ },
"12x8": { /* 12×8 pixel font data */ }
};
- User Input → Mouse event handling → Matrix data update
- Matrix Data → Byte array generation → C code output
- Text Input → Font rendering → Matrix merging → Display update
- Project Save → JSON serialization → File download
- Project Load → File reading → JSON parsing → Matrix reconstruction
-
Drawing Pixels
- Left click: Draw pixel
- Right click or Ctrl+Left click: Erase pixel
- Drag: Continuous drawing or erasing
-
Size Adjustment
- Modify width/height input boxes (1-128 pixels)
- Real-time grid size adjustment
-
Code Generation
- Click "Generate" button
- View C language byte array in output area
The text input functionality is a major highlight of this tool, providing professional-grade text rendering capabilities:
Basic Operation Flow:
- Click "Text Input" button to open the text editor
- Enter content to render in the text area (supports multi-line text)
- Select font specification:
- 7×6 Pixel Font: Compact font, suitable for small displays
- 12×8 Pixel Font: Standard font, suitable for medium-sized displays
- Configure typography parameters:
- Alignment: Left/Center/Right alignment
- X Position: Horizontal offset (pixel-level precision)
- Y Position: Vertical offset (pixel-level precision)
- Choose rendering mode:
- Merge Mode: Overlay with existing content
- Replace Mode: Clear existing content before rendering
- Real-time Preview: View final effects in preview area
- Confirm and click "Apply"
Advanced Features:
- Character Integrity Check: Automatically detect unsupported characters and provide alternatives
- Intelligent Boundary Handling: Automatically handle text exceeding grid boundaries
- Multi-line Text Support: Use line breaks to create multi-line display effects
- Position Guidance: Visual display of text area boundaries
- Undo Support: Use "Clear" function to undo text rendering
Font Technical Details:
- All fonts are hand-optimized bitmap fonts
- Each character is optimized for dot matrix displays
- Supports complete ASCII character set (32-126)
- Character spacing carefully adjusted for optimal readability
- Row Major: Row scanning, suitable for row-scan displays
- Column Major: Column scanning, suitable for column-scan displays
- Column+Row: 8-pixel grouped column scanning, commonly used for OLED displays
- Big Endian: High byte first, suitable for most embedded systems
- Little Endian: Low byte first, suitable for x86 architecture
- Click "Save" button
- Automatically download JSON format project file
- Filename includes timestamp:
dot_matrix_YYYY-MM-DD_HH-MM-SS.json
- Click "Load" button
- Select previously saved JSON file
- Automatically restore all settings and pixel data
- Paste existing C byte array code in output area
- Click "Import" button
- Automatically parse and display in grid
- Click "Export JSON" button
- Download JSON file containing complete project data
- Click "Export Code" button
- Download .c file containing C language byte array
// Column scanning in groups of 8 pixels
for (var yBlock = 0; yBlock < paddedHeight; yBlock += 8) {
for (var x = 0; x < width; x++) {
var newByte = 0;
for (var bit = 0; bit < 8; bit++) {
var y = yBlock + bit;
var bitVal = (y < height && matrix[y][x]) ? 1 : 0;
newByte |= bitVal << (msbendian ? (7 - bit) : bit);
}
bytes.push(newByte);
}
}
// Row-by-row pixel scanning
for (var y = 0; y < height; y++) {
for (var x = 0; x < width; x++) {
buffer[y * width + x] = matrix[y][x];
}
}
Each character is defined as a 2D array:
"A": [
[0,1,1,1,0,0],
[1,0,0,0,1,0],
[1,0,0,0,1,0],
[1,1,1,1,1,0],
[1,0,0,0,1,0],
[1,0,0,0,1,0],
[1,0,0,0,1,0]
]
- Chrome 60+
- Firefox 55+
- Safari 12+
- Edge 79+
├── index.html # Main page
├── app.js # Core logic
├── embedded-fonts.js # Font data
├── language.js # Multi-language support
├── cover.css # Style file
├── readme_cn.md # Chinese documentation
├── readme_en.md # English documentation
└── .gitignore # Git ignore file
- Clone the project locally
- Open with a web server (such as Live Server)
- Or directly open index.html in browser
- Define character data in
embedded-fonts.js
- Register new font in
FontManager.loadFont()
- Add option in text input dialog
- Add translations in
LANGUAGE
object inlanguage.js
- Add new option in language switch buttons
- Update
updateUILanguage()
function
- Arduino + OLED display projects
- STM32 + LCD display applications
- Raspberry Pi display projects
- Microcontroller character displays
- Custom font creation
- Pixel art design
- Icon prototyping
- Dot matrix animation frame design
- Digital image processing teaching
- Embedded systems courses
- Computer graphics experiments
- Programming education tools
- Efficient 2D array operations
- Optimized font data caching
- Minimal DOM manipulation
- CSS-based grid rendering
- Hardware-accelerated transforms
- Responsive cell sizing
- Optimized byte packing algorithms
- Efficient bit manipulation
- Minimal memory allocation
The tool supports three main byte ordering modes:
-
Row Major: Sequential row scanning
- Best for: Traditional LCD controllers
- Memory layout:
[row0][row1][row2]...
-
Column Major: Sequential column scanning
- Best for: Vertical scanning displays
- Memory layout:
[col0][col1][col2]...
-
Column+Row Hybrid: 8-pixel vertical blocks
- Best for: SSD1306 OLED controllers
- Memory layout:
[8-pixel vertical blocks]
The embedded font system uses a hierarchical structure:
FONT_DATA = {
"fontName": {
"name": "Display Name",
"width": pixelWidth,
"height": pixelHeight,
"characters": {
"char": [[pixel_matrix]]
}
}
}
- C Array: Standard embedded C format
- JSON Project: Complete project state
- Binary Data: Raw byte sequences (future feature)
- Grid not displaying: Check browser JavaScript support
- Font not loading: Verify embedded-fonts.js is loaded
- Export not working: Check browser download permissions
- Import failing: Verify C array format syntax
- Use smaller grid sizes for better performance
- Clear unused pixels to reduce memory usage
- Use appropriate byte order for your target hardware
// Matrix operations
createArray(height, width)
updateTable()
generateByteArray()
// Font operations
FontManager.loadFont(fontName, callback)
TextRenderer.renderText(fontName, text, alignment)
// File operations
saveMatrix()
loadMatrix(event)
exportCode()
This project is based on the open-source project dotmatrixtool by Stefan Gordon. We thank the original author for providing an excellent foundation framework. Building upon this base, we have added the following significant features:
- Complete Chinese and English bilingual support
- Advanced text input and rendering system
- Built-in font library (7×6 and 12×8 pixel fonts)
- Project file save/load functionality
- Code import/export functionality
- Real-time preview system
- Responsive interface design
- Enhanced user experience
The original project provided the core matrix editing functionality and basic code generation. Our enhancements focus on usability, internationalization, and advanced text handling capabilities, making it a more comprehensive tool for embedded display development.
Author: Taber.Huang
Email: [email protected]
Version: v0.1.0
Release Date: Sept 11, 2025
This project is open-sourced under the MIT License. See the LICENSE file for details.
Issues and Pull Requests are welcome to improve this project.
- Additional font sizes (5×7, 8×8, 16×16)
- Image import functionality
- Animation frame support
- Custom color themes
- Keyboard shortcuts
- Undo/Redo functionality
- Grid guidelines and rulers
- Batch export capabilities
- WebAssembly optimization for large grids
- Progressive Web App (PWA) support
- Cloud storage integration
- Collaborative editing features
- Plugin system for custom exporters
- Mobile app versions