static void jzlcd_start(struct jzlcd_softc *sc) { uint32_t ctrl; /* Clear status registers */ LCD_WRITE(sc, LCDSTATE, 0); LCD_WRITE(sc, LCDOSDS, 0); /* Enable the controller */ ctrl = LCD_READ(sc, LCDCTRL); ctrl |= LCDCTRL_ENA; ctrl &= ~LCDCTRL_DIS; LCD_WRITE(sc, LCDCTRL, ctrl); }
static void jzlcd_stop(struct jzlcd_softc *sc) { uint32_t ctrl; ctrl = LCD_READ(sc, LCDCTRL); if ((ctrl & LCDCTRL_ENA) != 0) { /* Disable the controller and wait for it to stop */ ctrl |= LCDCTRL_DIS; LCD_WRITE(sc, LCDCTRL, ctrl); while ((LCD_READ(sc, LCDSTATE) & LCDSTATE_LDD) == 0) DELAY(100); } /* Clear all status except for disable */ LCD_WRITE(sc, LCDSTATE, LCD_READ(sc, LCDSTATE) & ~LCDSTATE_LDD); }
void main(void) { unsigned char count=0; // Counter variable LCD_INIT(); LCD_CMD(LINE1); LCD_WRITE("**BALL-COUNTER**"); LCD_CMD(DON_COFF); counter_display(count); while(1) { if(touch_sensor==0)//If Touch detected { count++; //Counter incremented counter_display(count); //Display Number buzzer=0; //Buzzer ON delay_ms(1000); //Delay for correction if any } else { buzzer=1; //Buzzer OFF } } }
static int jzlcd_set_videomode(struct jzlcd_softc *sc, const struct videomode *mode) { u_int hbp, hfp, hsw, vbp, vfp, vsw; u_int hds, hde, ht, vds, vde, vt; uint32_t ctrl; int error; hbp = mode->htotal - mode->hsync_end; hfp = mode->hsync_start - mode->hdisplay; hsw = mode->hsync_end - mode->hsync_start; vbp = mode->vtotal - mode->vsync_end; vfp = mode->vsync_start - mode->vdisplay; vsw = mode->vsync_end - mode->vsync_start; hds = hsw + hbp; hde = hds + mode->hdisplay; ht = hde + hfp; vds = vsw + vbp; vde = vds + mode->vdisplay; vt = vde + vfp; /* Setup timings */ LCD_WRITE(sc, LCDVAT, (ht << LCDVAT_HT_SHIFT) | (vt << LCDVAT_VT_SHIFT)); LCD_WRITE(sc, LCDDAH, (hds << LCDDAH_HDS_SHIFT) | (hde << LCDDAH_HDE_SHIFT)); LCD_WRITE(sc, LCDDAV, (vds << LCDDAV_VDS_SHIFT) | (vde << LCDDAV_VDE_SHIFT)); LCD_WRITE(sc, LCDHSYNC, hsw); LCD_WRITE(sc, LCDVSYNC, vsw); /* Set configuration */ LCD_WRITE(sc, LCDCFG, LCDCFG_NEWDES | LCDCFG_RECOVER | LCDCFG_24 | LCDCFG_PSM | LCDCFG_CLSM | LCDCFG_SPLM | LCDCFG_REVM | LCDCFG_PCP); ctrl = LCD_READ(sc, LCDCTRL); ctrl &= ~LCDCTRL_BST; ctrl |= LCDCTRL_BST_64 | LCDCTRL_OFUM; LCD_WRITE(sc, LCDCTRL, ctrl); LCD_WRITE(sc, LCDPCFG, PCFG_MAGIC); LCD_WRITE(sc, LCDRGBC, LCDRGBC_RGBFMT); /* Update registers */ LCD_WRITE(sc, LCDSTATE, 0); /* Setup frame descriptors */ jzlcd_setup_descriptor(sc, mode, 0); jzlcd_setup_descriptor(sc, mode, 1); bus_dmamap_sync(sc->fdesc_tag, sc->fdesc_map, BUS_DMASYNC_PREWRITE); /* Setup DMA channels */ LCD_WRITE(sc, LCDDA0, sc->fdesc_paddr + sizeof(struct lcd_frame_descriptor)); LCD_WRITE(sc, LCDDA1, sc->fdesc_paddr); /* Set display clock */ error = clk_set_freq(sc->clk_pix, DOT_CLOCK_TO_HZ(mode->dot_clock), 0); if (error != 0) { device_printf(sc->dev, "failed to set pixel clock to %u Hz\n", DOT_CLOCK_TO_HZ(mode->dot_clock)); return (error); } return (0); }
// ----------------------------------------------------------------------------- // Outputs a character on the display, using the given font and style // uint8_t lcd_put_char(FONT_P font, uint8_t style, char character) { int8_t i; uint8_t row = 0; // current row of char uint8_t hc = (style & DOUBLE_HEIGHT) ? 1 : 0; // height change uint8_t wc = (style & DOUBLE_WIDTH) ? 1 : 0; // width change uint8_t ul = (style & UNDERLINE) ? 0x80 : 0x00; // underline uint8_t inv = (style & INVERT) ? 0xFF : 0; // inverted uint8_t tmp; // load information about character uint8_t char_width = font_get_char_width(font, character); uint8_t font_height = font_get_height_bytes(font); uint8_t free_space = font_get_add_space(font, character); PGM_P tableposition = font_get_char_position(font, character); // final size of character uint8_t char_final_width = (uint8_t)(char_width + free_space) << wc; uint8_t char_final_height = (uint8_t)font_height << hc; // check for avail. space on display if ((style & WRAP) && (LCD_CURRENT_COL() + char_final_width > LCD_WIDTH)) { LCD_MOVE_TO(LCD_CURRENT_PAGE() + char_final_height, 0); if (character == ' ') { return 0; } } // write chracter do { for (i = (row >> hc); i < char_width / font_height; i += font_height) { tmp = pgm_read_byte(tableposition + i); if (row == char_final_height - 1) { tmp |= ul; } if (hc) { tmp = double_bits((row & 1), tmp); } if (inv) { tmp = ~tmp; } LCD_WRITE(tmp); if (wc) { LCD_WRITE(tmp); } } if (free_space) { uint8_t c = inv; if (row == char_final_height - 1) { c ^= ul; if (hc) { c ^= ul >> 1; } } LCD_WRITE(c); if (wc) { LCD_WRITE(c); } } LCD_MOVE(1, -char_final_width); } while (++row < char_final_height);