<commit_before>/******************************************************************************
 *
 * grl_pcd8544_84x48.c - TI Stellaris graphics library display driver for
 *                       PCD8544 controller, used in Nokia 5110/3310 displays
 *
 * Copyright (c) 2013, <NAME> (k<EMAIL>)
 * All rights reserved.
 *
 * This software is released under the FreeBSD license, found in the
 * accompanying file LICENSE.txt and at the following URL:
 *      http://www.freebsd.org/copyright/freebsd-license.html
 *
 * This software is provided as-is and without warranty.
 *
 *****************************************************************************/

#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>

#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/ssi.h"
#include "driverlib/pin_map.h"
#include "grlib/grlib.h"

#include "grl_pcd8544_84x48.h"

/******************************************************************************
 *
 * This is a display driver for the Philips PCD8544 84 x 48 pixel LCD
 * controller.  This is the controller used in Nokia 5110/3310 displays that
 * can be found at adafruit or sparkfun.  This display driver is meant to be
 * used with the TI StellarisWare graphics library (grlib).
 *
 * Please refer to the StellarisWare graphics library user manual in your
 * StellarisWare distribution (SW-GRL-nnnn.pdf, found in the docs directory).
 *
 * This driver uses a frame buffer so you must call GrFlush() after all
 * primitive operations in order to update the screen.
 *
 * This is a monochrome display so it is 1-bit per pixel and the only grlib
 * color choices are ClrWhite and ClrBlack.  ClrBlack will be interpreted as
 * pixel off, while ClrWhite and any other non-black color will be
 * interpreted as pixel on.
 *
 * TODO:
 *  - add reset line control
 *    right now I assume display reset is tied to Stellaris board reset
 *  - add LED backlight control
 *    right now you can tie LED control signal high or low
 *  - make driver interrupt driven
 *  - add auto flush and dirty rectangle tracking
 *  - bounds checking
 *
 * EXAMPLE:
 *  Here is code showing how you might use this driver in an example:
 *
 *    // init the driver
 *    GRL_PCD8544_84x48_Init(SysCtlClockGet());
 *
 *    // init the grlib graphics context
 *    GrContextInit(&context, &g_sPCD8544_84x48);
 *
 *    // define rectangle for screen border
 *    rect.sXMin = 0;
 *    rect.sYMin = 0;
 *    rect.sXMax = GrContextDpyWidthGet(&context) - 1;
 *    rect.sYMax = 23;
 *
 *    // set foreground color (note, white means pixel on)
 *    // draw the rectangle
 *    GrContextForegroundSet(&context, ClrWhite);
 *    GrRectDraw(&context, &rect);
 *
 *    // set the font for text
 *    GrContextFontSet(&context, g_pFontFixed6x8);
 *
 *    // write a string to the screen
 *    GrStringDrawCentered(&context, "Hello", -1, 
 *                         GrContextDpyWidthGet(&context) / 2, 10, 0);
 *
 *    // flush the frame buffer - this will update all prior operations
 *    // to screen
 *    GrFlush(&context);
 *
 *****************************************************************************/

/******************************************************************************
 *
 * Macros
 *
 *****************************************************************************/

/* Define the GPIO ports and pins used for the SSI/SPI peripheral
 */
#define DISPLAY_GPIO_PERIPH     SYSCTL_PERIPH_GPIOB
#define DISPLAY_PINCFG_SSICLK   GPIO_PB4_SSI2CLK
#define DISPLAY_PINCFG_SSIFSS   GPIO_PB5_SSI2FSS
#define DISPLAY_PINCFG_SSITX    GPIO_PB7_SSI2TX
#define DISPLAY_GPIO_PORT       GPIO_PORTB_BASE
#define DISPLAY_GPIO_PINS       (GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_7)
#define DISPLAY_DC_PIN          GPIO_PIN_6

/* Define the SSI/SPI peripheral to use with the display, data rate
 */
#define DISPLAY_SSI_PERIPH      SYSCTL_PERIPH_SSI2
#define DISPLAY_SSI_BASE        SSI2_BASE
#define DISPLAY_SSI_RATE        1000000

/******************************************************************************
 *
 * Locals
 *
 *****************************************************************************/

/* Create the frame buffer for the display.  We must use a frame buffer
 * because it is necessary to modify individual bits within bytes.  Therefore
 * the existing value of each byte for the display must be stored somewhere
 * and it is not possible to read it from the display.
 */<commit_msg>Changed from SSI2 to SSI0 to control the display, because the SSI2 pins were causing some conflicts on the Stellaris LaunchPad when combined with the servo board.<commit_after>/******************************************************************************
 *
 * grl_pcd8544_84x48.c - TI Stellaris graphics library display driver for
 *                       PCD8544 controller, used in Nokia 5110/3310 displays
 *
 * Copyright (c) 2013, <NAME> (kroesche.org)
 * All rights reserved.
 *
 * This software is released under the FreeBSD license, found in the
 * accompanying file LICENSE.txt and at the following URL:
 *      http://www.freebsd.org/copyright/freebsd-license.html
 *
 * This software is provided as-is and without warranty.
 *
 *****************************************************************************/

#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>

#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/ssi.h"
#include "driverlib/pin_map.h"
#include "grlib/grlib.h"

#include "grl_pcd8544_84x48.h"

/******************************************************************************
 *
 * This is a display driver for the Philips PCD8544 84 x 48 pixel LCD
 * controller.  This is the controller used in Nokia 5110/3310 displays that
 * can be found at adafruit or sparkfun.  This display driver is meant to be
 * used with the TI StellarisWare graphics library (grlib).
 *
 * Please refer to the StellarisWare graphics library user manual in your
 * StellarisWare distribution (SW-GRL-nnnn.pdf, found in the docs directory).
 *
 * This driver uses a frame buffer so you must call GrFlush() after all
 * primitive operations in order to update the screen.
 *
 * This is a monochrome display so it is 1-bit per pixel and the only grlib
 * color choices are ClrWhite and ClrBlack.  ClrBlack will be interpreted as
 * pixel off, while ClrWhite and any other non-black color will be
 * interpreted as pixel on.
 *
 * TODO:
 *  - add reset line control
 *    right now I assume display reset is tied to Stellaris board reset
 *  - add LED backlight control
 *    right now you can tie LED control signal high or low
 *  - make driver interrupt driven
 *  - add auto flush and dirty rectangle tracking
 *  - bounds checking
 *
 * EXAMPLE:
 *  Here is code showing how you might use this driver in an example:
 *
 *    // init the driver
 *    GRL_PCD8544_84x48_Init(SysCtlClockGet());
 *
 *    // init the grlib graphics context
 *    GrContextInit(&context, &g_sPCD8544_84x48);
 *
 *    // define rectangle for screen border
 *    rect.sXMin = 0;
 *    rect.sYMin = 0;
 *    rect.sXMax = GrContextDpyWidthGet(&context) - 1;
 *    rect.sYMax = 23;
 *
 *    // set foreground color (note, white means pixel on)
 *    // draw the rectangle
 *    GrContextForegroundSet(&context, ClrWhite);
 *    GrRectDraw(&context, &rect);
 *
 *    // set the font for text
 *    GrContextFontSet(&context, g_pFontFixed6x8);
 *
 *    // write a string to the screen
 *    GrStringDrawCentered(&context, "Hello", -1, 
 *                         GrContextDpyWidthGet(&context) / 2, 10, 0);
 *
 *    // flush the frame buffer - this will update all prior operations
 *    // to screen
 *    GrFlush(&context);
 *
 *****************************************************************************/

/******************************************************************************
 *
 * Macros
 *
 *****************************************************************************/

/* Define the GPIO ports and pins used for the SSI/SPI peripheral
 */
#define DISPLAY_GPIO_PERIPH     SYSCTL_PERIPH_GPIOA
#define DISPLAY_PINCFG_SSICLK   GPIO_PA2_SSI0CLK
#define DISPLAY_PINCFG_SSIFSS   GPIO_PA3_SSI0FSS
#define DISPLAY_PINCFG_SSITX    GPIO_PA5_SSI0TX
#define DISPLAY_GPIO_PORT       GPIO_PORTA_BASE
#define DISPLAY_GPIO_PINS       (GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_5)
#define DISPLAY_DC_PIN          GPIO_PIN_4

/* Define the SSI/SPI peripheral to use with the display, data rate
 */
#define DISPLAY_SSI_PERIPH      SYSCTL_PERIPH_SSI0
#define DISPLAY_SSI_BASE        SSI0_BASE
#define DISPLAY_SSI_RATE        1000000

/******************************************************************************
 *
 * Locals
 *
 *****************************************************************************/

/* Create the frame buffer for the display.  We must use a frame buffer
 * because it is necessary to modify individual bits within bytes.  Therefore
 * the existing value of each byte for the display must be stored somewhere
 * and it is not possible to read it from the display.
 */
{'fraction_non_alphanumeric': 0.20468220107209276, 'fraction_numerical': 0.02133245815556285, 'mean_word_length': 3.8705380927011186, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '724442', 'n_tokens_mistral': 2755, 'n_tokens_neox': 2544, 'n_words': 902}