@@ -8,6 +8,7 @@ The library is organized into three main modules:
88
99- ** Math** - Vector operations and mathematical utilities (conversions, interpolation, random numbers)
1010- ** Graphics** - Color manipulation and geometric primitives (line segments, color utilities)
11+ - ** Serial** - Web Serial API wrapper for communication with microcontrollers (Arduino, ESP32)
1112- ** Logo** - Interactive Makeability Lab logo components with animation support
1213
1314Each module can be imported independently or as a complete bundle, allowing for optimized loading based on your needs.
@@ -22,6 +23,7 @@ The easiest way to use this library is via CDN. No installation required - just
2223 // Import specific modules
2324 import { Vector , lerp } from ' https://cdn.jsdelivr.net/gh/makeabilitylab/js@main/dist/makelab.math.js' ;
2425 import { lerpColor } from ' https://cdn.jsdelivr.net/gh/makeabilitylab/js@main/dist/makelab.graphics.js' ;
26+ import { Serial , SerialEvents } from ' https://cdn.jsdelivr.net/gh/makeabilitylab/js@main/dist/makelab.serial.js' ;
2527 import { MakeabilityLabLogo } from ' https://cdn.jsdelivr.net/gh/makeabilitylab/js@main/dist/makelab.logo.js' ;
2628
2729 // Or import everything
@@ -46,12 +48,14 @@ https://cdn.jsdelivr.net/gh/makeabilitylab/js@main/dist/{filename}
4648// Specific modules
4749https: // cdn.jsdelivr.net/gh/makeabilitylab/js@main/dist/makelab.math.js
4850https: // cdn.jsdelivr.net/gh/makeabilitylab/js@main/dist/makelab.graphics.js
51+ https: // cdn.jsdelivr.net/gh/makeabilitylab/js@main/dist/makelab.serial.js
4952https: // cdn.jsdelivr.net/gh/makeabilitylab/js@main/dist/makelab.logo.js
5053https: // cdn.jsdelivr.net/gh/makeabilitylab/js@main/dist/makelab.all.js
5154
5255// Minified versions (recommended for production)
5356https: // cdn.jsdelivr.net/gh/makeabilitylab/js@main/dist/makelab.math.min.js
5457https: // cdn.jsdelivr.net/gh/makeabilitylab/js@main/dist/makelab.graphics.min.js
58+ https: // cdn.jsdelivr.net/gh/makeabilitylab/js@main/dist/makelab.serial.min.js
5559https: // cdn.jsdelivr.net/gh/makeabilitylab/js@main/dist/makelab.logo.min.js
5660https: // cdn.jsdelivr.net/gh/makeabilitylab/js@main/dist/makelab.all.min.js
5761```
130134│ ├── lib/
131135│ │ ├── math/ # Math utilities and Vector class
132136│ │ ├── graphics/ # Graphics utilities (colors, line segments)
137+ │ │ ├── serial/ # Web Serial API wrapper
133138│ │ └── logo/ # Makeability Lab logo components
134139│ └── apps/ # Example applications
135140├── dist/ # Built output files
150155- ` LineSegment ` - Line segment operations and intersections
151156- ` lerpColor() ` - Interpolate between colors
152157- ` convertColorStringToObject() ` - Parse color strings to RGB objects
158+ - ` hsvToRgb() ` - Convert HSV to RGB
159+ - ` rgbToHsv() ` - Convert RGB to HSV
160+ - ` rgbToHex() ` - Convert RGB to hex string
161+ - ` hexStringToRgb() ` - Convert hex string to RGB
162+ - ` changeColorBrightness() ` - Adjust color brightness
163+ - ` changeColorSaturationAndBrightness() ` - Adjust color saturation and brightness
164+
165+ #### Serial Module
166+ - ` Serial ` - Event-driven Web Serial API wrapper for text-based communication
167+ - ` SerialEvents ` - Event type constants (` CONNECTION_OPENED ` , ` CONNECTION_CLOSED ` , ` DATA_RECEIVED ` , ` ERROR_OCCURRED ` )
168+ - ` SerialState ` - Connection state constants (` CLOSED ` , ` OPENING ` , ` OPEN ` , ` CLOSING ` )
169+ - ` LineBreakTransformer ` - Stream transformer for line-delimited serial data
153170
154171#### Logo Module
155172- ` MakeabilityLabLogo ` - Main logo component
@@ -173,6 +190,7 @@ This command generates the following files in the `dist/` directory:
173190| --------| ----------| ----------|
174191| Math | ` makelab.math.js ` | ` makelab.math.min.js ` |
175192| Graphics | ` makelab.graphics.js ` | ` makelab.graphics.min.js ` |
193+ | Serial | ` makelab.serial.js ` | ` makelab.serial.min.js ` |
176194| Logo | ` makelab.logo.js ` | ` makelab.logo.min.js ` |
177195| All (Complete) | ` makelab.all.js ` | ` makelab.all.min.js ` |
178196
@@ -397,6 +415,38 @@ line.getIntersection(otherLine) // Get intersection point
397415``` javascript
398416lerpColor (color1, color2, amount) // Blend two colors
399417convertColorStringToObject (colorString) // Parse color to RGB
418+ hsvToRgb (h, s, v) // HSV (0–1) to RGB object
419+ rgbToHsv (r, g, b) // RGB (0–255) to HSV object
420+ rgbToHex (r, g, b) // RGB to hex string
421+ hexStringToRgb (hex) // Hex string to RGB object
422+ changeColorBrightness (color, percent) // Adjust brightness
423+ ```
424+
425+ ### Serial Module
426+
427+ ``` javascript
428+ const serial = new Serial ()
429+
430+ // Events
431+ serial .on (SerialEvents .DATA_RECEIVED , (sender , line ) => { ... })
432+ serial .on (SerialEvents .CONNECTION_OPENED , (sender ) => { ... })
433+ serial .on (SerialEvents .CONNECTION_CLOSED , (sender ) => { ... })
434+ serial .on (SerialEvents .ERROR_OCCURRED , (sender , error ) => { ... })
435+ serial .off (event , callback) // Remove a listener
436+
437+ // Connection
438+ serial .connectAndOpen (filters, options) // Prompt user + open (requires user gesture)
439+ serial .autoConnectAndOpenPreviouslyApprovedPort (options) // Reconnect without gesture
440+ serial .close () // Close and release resources
441+
442+ // I/O
443+ serial .writeLine (text) // Send text + newline
444+ serial .write (text) // Send text
445+
446+ // State
447+ serial .isOpen () // Boolean
448+ serial .state // "closed" | "opening" | "open" | "closing"
449+ Serial .isWebSerialSupported () // Static browser check
400450```
401451
402452### Logo Module
@@ -431,4 +481,4 @@ For questions, issues, or contributions, please visit the project repository.
431481
432482---
433483
434- Built with Rollup | Powered by JavaScript ES6+ Modules
484+ Built with Rollup | Powered by JavaScript ES6+ Modules
0 commit comments