This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C129XNCZAD: problem in setting voltage through from lcd using slider

Part Number: TM4C129XNCZAD

dear all,

 i dont know how to use slider in graphics library although i tried to get it from example. my problem is to get the value from slider and pass it to to DAC . so i am unable to get value from slider. onsliderchange function i dont know how to write in it. please help. i am writing code

#include "stdbool.h"
#include "stdint.h"
#include "gpio.h"
#include "rom_map.h"
#include "sysctl.h"
#include "inc/hw_memmap.h"
#include "pin_map.h"
#include "emac.h"
#include "systick.h"
#include "drivers/pinout.h"
#include "utils/ustdlib.h"
#include "driverlib/adc.h"
#include "math.h"
#include "driverlib/ssi.h"
#include "inc/tm4c129xnczad.h"
#include "grlib/grlib.h"
#include "grlib/widget.h"
#include "grlib/canvas.h"
#include "grlib/slider.h"
#include "drivers/frame.h"
#include "drivers/kentec320x240x16_ssd2119.h"
#include "drivers/sound.h"
#include "drivers/touch.h"
#include "driverlib/rom.h"
uint32_t ui32SysClock;
void PinoutSet(void);
void DisplayInitialize(void);
#define SYS_TICK_DELAY 10000
#define GPIO_PA2_SSI0CLK        0x0000080F
#define GPIO_PA3_SSI0FSS        0x00000C0F
#define GPIO_PA4_SSI0TX      0x0000100F
#define GPIO_PA5_SSI0RX      0x0000140F
void Touch_interface(void);

volatile uint32_t ui32Loop;
void OnSliderChange(tWidget *psWidget, int32_t i32Value);
void clrScreen(void);
void DisplayInitialize(void);
tContext sContext;
tRectangle sRect;
extern tCanvasWidget g_sBackground;
extern tSliderWidget g_psSliders;

Canvas(g_sHeading, &g_sBackground, 0, &g_psSliders,
&g_sKentec320x240x16_SSD2119, 0, 0, 320, 23,
(CANVAS_STYLE_FILL | CANVAS_STYLE_OUTLINE | CANVAS_STYLE_TEXT),
ClrBlack, ClrWhite, ClrRed, g_psFontCm20, "Slider Control", 0, 0);
Canvas(g_sBackground, WIDGET_ROOT, 0, &g_sHeading,
&g_sKentec320x240x16_SSD2119, 0, 23, 320, (240 - 23),
CANVAS_STYLE_FILL, ClrBlack, 0, 0, 0, 0, 0, 0);
Slider(g_psSliders,&g_sHeading, 0, 0,
                 &g_sKentec320x240x16_SSD2119, 10, 105, 220, 30, 0, 100, 25,
                 (SL_STYLE_FILL | SL_STYLE_BACKG_FILL | SL_STYLE_OUTLINE |
                  SL_STYLE_TEXT | SL_STYLE_BACKG_TEXT),
                 ClrGray, ClrBlack, ClrSilver, ClrWhite, ClrWhite,
                 g_psFontCm20, "25%", 0, 0, OnSliderChange);
void SysTickIntHandler()
{
    /* ------------ LwIP Timer  ----------------------------- */

}
/*
void MT_SysTick_Set()
{
    SysTickPeriodSet(((ui32SysClock / 1000000) * SYS_TICK_DELAY));  // load count
    SysTickIntRegister(SysTickIntHandler);  // int handler Register
    SysTickIntEnable();             // Enable Systick interrupt
    SysTickEnable();                // Enable Systick

}
*/
void
OnSliderChange(tWidget *psWidget, int32_t i32Value)
{

}
void DAC_ldac()
{
    ///  LDAC Signal
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    MAP_GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_5);
    MAP_GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_5, GPIO_PIN_5);
   // Reset Signal
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    MAP_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_3);
    MAP_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3, 0);
}

int main(void)
{
    uint32_t pui32DataTx;
    volatile uint32_t ui32Loop;

    ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_320),
        2000000);
//     MT_SysTick_Set();
    DAC_ldac();
    DisplayInitialize();

    SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    GPIOPinConfigure(GPIO_PA2_SSI0CLK);
    GPIOPinConfigure(GPIO_PA3_SSI0FSS);
    GPIOPinConfigure(GPIO_PA4_SSI0TX);
    GPIOPinConfigure(GPIO_PA5_SSI0RX);
    GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_5 | GPIO_PIN_4 | GPIO_PIN_3 | GPIO_PIN_2);
    SSIConfigSetExpClk(SSI0_BASE, ui32SysClock, SSI_FRF_MOTO_MODE_3,
                        SSI_MODE_MASTER, 10000, 16);


    SSIEnable(SSI0_BASE);

    while(1)
        {

       // SysCtlDelay(10);
        MAP_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3, GPIO_PIN_3);
        MAP_GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_5,GPIO_PIN_5); //ldac

        pui32DataTx=0xafff;
        SSIDataPut(SSI0_BASE, pui32DataTx);
                while(SSIBusy(SSI0_BASE))
                    {
                    }
                MAP_GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_5, 0);
             //   SSIIntClear(SSI0_BASE,SSI_RXFF);
                SysCtlDelay(10);

                MAP_GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_5,GPIO_PIN_5);

        }


        }

void clrScreen()
{
    sRect.i16XMin = 0;
    sRect.i16YMin = 0;
    sRect.i16XMax = 319;
    sRect.i16YMax = 239;
    GrContextForegroundSet(&sContext, ClrBlack);
    GrRectFill(&sContext, &sRect);
    GrFlush(&sContext);
}

void DisplayInitialize()
{
    Kentec320x240x16_SSD2119Init(ui32SysClock);
    GrContextInit(&sContext, &g_sKentec320x240x16_SSD2119);
    PinoutSet();
    TouchScreenInit(ui32SysClock);
    TouchScreenCallbackSet(WidgetPointerMessage);
    WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sBackground);
    WidgetPaint(WIDGET_ROOT);
    clrScreen();

}

  • gurpreet singh96 said:
    I dont know how to use slider in graphics library ...  my problem is to get the value from slider and pass it to to DAC

    Looking at your code (which like another's code listing here) is remarkably/notably "Comment FREE" reveals the function, "OnSliderChange()" - which is empty.     Some (perhaps many) rising to your aid here - may not have familiarity w/"Vendors Graphic Lib."      Thus we must ask you - is function, "OnSliderChange()" your creation?     (the emptiness of that function suggests, "your creation.")

    I've searched - yet could not find - "clearly listed "Slider Initialization."      Minus such "known & starting Slider value" - how can "OnSliderChange()" function?     Should it not require "regular "reads" of the Slider Position" - and then (and only then) - to present that "current Slider data" to "OnSliderChange()" for processing & screen update?

    Neither firm nor I use vendor's graphic lib.     (we've built our own - better accommodating, modern/advanced displays.)      

    You note your "weakness" w/"slider" - yet do not reveal why that is the case.     Is "slider" nowhere explained and/or detailed?     If so - how hard/long/focused has been your search?     (it is always helpful to others - when you "organize & ease" their efforts - that should be your goal...)

    You may search the graphic lib - keyword "slider" - seeking its "position read" (or similar description) which should be a, "Regularly called function."     (slider must be read repeatedly - so that (any) slider change becomes "detectable" - is that (now) clear?

    You've well identified your objective, "Get the value from slider" - I've attempted to guide you in that process.     Your quote closes w/"pass to DAC" - which w/out (proper) detail and definition - escapes my understanding...     (A "normal" mechanical "slider" is a linear "pot" - which feeds the MCU's ADC.)     It is expected that "slider, here" is a screen-drawn one (virtual?) - and unless the "slider" is to "Always output voltage (via the DAC - which limits its use & effectiveness) more explanation is required...    (our use of such "slider-like" function (w/in our own gra lib) enables "DAC drive OR "Value Setting" (w/out DAC impact) depending upon the addressed function - thus greatly expanding utility!)

  • thnx i did it with your support
  • Good for you!    (et   Mercî mon ami.)

    Yet "Good for MANY here" would be (some) description of  "HOW you got the slider function to detect value" (initially & then on-going) - and then, "test for change in slider value."