@@ -24,6 +24,7 @@ export class LCD1602Element extends LitElement {
2424 @property ( ) cursorY = 0 ;
2525 @property ( ) backlight = true ;
2626 @property ( ) pins : 'full' | 'i2c' | 'none' = 'full' ;
27+ @property ( ) screenOnly = false ;
2728
2829 protected numCols = 16 ;
2930 protected numRows = 2 ;
@@ -221,8 +222,14 @@ export class LCD1602Element extends LitElement {
221222 background in backgroundColors ? backgroundColors [ background ] : backgroundColors ;
222223
223224 const panelWidth = cols * 3.5125 ;
224- const width = panelWidth + 23.8 ;
225- const height = panelHeight + 24.5 ;
225+ const width = this . screenOnly ? panelWidth : panelWidth + 23.8 ;
226+ const height = this . screenOnly ? panelHeight : panelHeight + 24.5 ;
227+
228+ const panelX = 12.45 ;
229+ const panelY = 12.55 ;
230+ const viewBox = this . screenOnly
231+ ? `${ panelX } ${ panelY } ${ panelWidth } ${ panelHeight } `
232+ : `0 0 ${ width } ${ height } ` ;
226233
227234 // Dimensions according to:
228235 // https://www.winstar.com.tw/products/character-lcd-display-module/16x2-lcd.html
@@ -231,7 +238,7 @@ export class LCD1602Element extends LitElement {
231238 width ="${ width } mm "
232239 height ="${ height } mm "
233240 version ="1.1 "
234- viewBox ="0 0 ${ width } ${ height } "
241+ viewBox ="${ viewBox } "
235242 style ="font-size: 1.5px; font-family: monospace "
236243 xmlns ="http://www.w3.org/2000/svg "
237244 >
@@ -277,13 +284,17 @@ export class LCD1602Element extends LitElement {
277284 ${ pins === 'i2c' ? this . renderI2CPins ( ) : null }
278285 ${ pins === 'full' ? this . renderPins ( panelHeight ) : null }
279286 < rect
280- x ="12.45 "
281- y ="12.55 "
287+ x ="${ panelX } "
288+ y ="${ panelY } "
282289 width ="${ panelWidth } "
283290 height ="${ panelHeight } "
284291 fill ="url(#characters) "
285292 />
286- < path d ="${ this . path ( characters ) } " transform ="translate(12.45, 12.55) " fill ="${ color } " />
293+ < path
294+ d ="${ this . path ( characters ) } "
295+ transform ="translate(${ panelX } , ${ panelY } ) "
296+ fill ="${ color } "
297+ />
287298 ${ this . renderCursor ( ) }
288299 </ svg >
289300 ` ;
0 commit comments