Ejemplo n.º 1
0
/* *********************************
   void serdisp_directgfx_init(dd)
   *********************************
   initialise
   *********************************
   dd     ... display descriptor
*/
void serdisp_directgfx_init(serdisp_t* dd) {
  char caption[40];
  SDL_Surface* screen;

  if (fp_SDL_Init(SDL_INIT_VIDEO) != 0) {
    sd_error(SERDISP_ENOTSUP, "%s(): unable to initialise SDL: %s", __func__, fp_SDL_GetError());
    sd_runtimeerror = 1;
    fp_SDL_Quit();
    return;
  }

  screen = serdisp_directgfx_internal_getStruct(dd)->screen = 
    (void*)fp_SDL_SetVideoMode(dd->width, dd->height, 0 /*sdl_depth*/, SDL_HWSURFACE | SDL_HWACCEL);

  if (screen == NULL) {
    sd_error(SERDISP_ENOTSUP, "%s(): unable to set video mode: %s", __func__, fp_SDL_GetError());
    sd_runtimeerror = 1;
    fp_SDL_Quit();
    return;
  }

  snprintf(caption, sizeof(caption)-1, "serdisplib::SDL %dx%dx%d", screen->w, screen->h, screen->format->BitsPerPixel);
  fp_SDL_WM_SetCaption(caption, NULL);

  sd_debug(2, "%s(): done with initialising", __func__);
}
Ejemplo n.º 2
0
void __log4c_reread(void)
{
    time_t file_ctime;
    int i;

    for (i = 0; i < nrcfiles; i++){
	/* only reread files that existed when we first initialized */
	if (rcfiles[i].exists && SD_STAT_CTIME(rcfiles[i].name,&file_ctime) == 0){
	    /* time_t is number of second since epoch, just compare for == */
	    if (file_ctime != rcfiles[i].ctime){
		sd_debug("Need reread on file %s\n",rcfiles[i].name);
		SD_STAT_CTIME(rcfiles[i].name,&rcfiles[i].ctime);
		if (log4c_rc_load(log4c_rc, rcfiles[i].name) == -1){
		    sd_error("re-loading config file %s failed", rcfiles[i].name);
		}
	    }
	}
    }
}
Ejemplo n.º 3
0
/* *********************************
   serdisp_t* serdisp_ssdoled_setup(sdcd, dispname, optionstring)
   *********************************
   sets up a display descriptor fitting to dispname and extra
   *********************************
   sdcd             ... output device handle (not used in here)
   dispname         ... display name (case-insensitive)
   optionstring     ... option string containing individual options
   *********************************
   returns a display descriptor
*/
serdisp_t* serdisp_ssdoled_setup(const serdisp_CONN_t* sdcd, const char* dispname, const char* optionstring) {
  serdisp_t* dd;

  if (! (dd = (serdisp_t*)sdtools_malloc(sizeof(serdisp_t)) ) ) {
    sd_error(SERDISP_EMALLOC, "serdisp_ssdoled_setup(): cannot allocate display descriptor");
    return (serdisp_t*)0;
  }
  memset(dd, 0, sizeof(serdisp_t));

  if (! (dd->specific_data = (void*) sdtools_malloc( sizeof(serdisp_ssdoled_specific_t)) )) {
    free(dd);
    return (serdisp_t*)0;
  }

  memset(dd->specific_data, 0, sizeof(serdisp_ssdoled_specific_t));

  /* "SSDxxxx"-based displays supported in here */
  /* assign dd->dsp_id */
  if (serdisp_comparedispnames("OLED96X36X1", dispname))
    dd->dsp_id = DISPID_OLED96X36X1;
  else if (serdisp_comparedispnames("OLED96X64X16", dispname))
    dd->dsp_id = DISPID_OLED96X64X16;
  else if (serdisp_comparedispnames("OLED128X64X4", dispname))
    dd->dsp_id = DISPID_OLED128X64X4;
  else if (serdisp_comparedispnames("BL160128A", dispname))
    dd->dsp_id = DISPID_BL160128A;
  else if (serdisp_comparedispnames("4DOLED282815", dispname))
    dd->dsp_id = DISPID_4DOLED282815;
  else {  /* should not occur */
    sd_error(SERDISP_ENOTSUP, "display '%s' not supported by serdisp_specific_ssdoled.c", dispname);
    return (serdisp_t*)0;
  }

  /* default setup for function pointers */
  dd->fp_init           = &serdisp_ssdoled_init;
  dd->fp_update         = &serdisp_ssdoled_update;
  dd->fp_close          = &serdisp_ssdoled_close;
  dd->fp_setoption      = &serdisp_ssdoled_setoption;
  dd->fp_getvalueptr    = &serdisp_ssdoled_getvalueptr;


  /* per display settings */

  dd->width             = 96;
  dd->height            = 36;
  dd->depth             = 1;
  dd->feature_contrast  = 1;
  dd->feature_backlight = 0;
  dd->feature_invert    = 1;

  dd->min_contrast      = 0;
  dd->max_contrast      = 0x3F;

  dd->startxcol         = 36;

  /* max. delta for optimised update algorithm */
  dd->optalgo_maxdelta  = 3;

  dd->delay = 0;
  serdisp_ssdoled_internal_getStruct(dd)->gstablecorr = 100; /* default grey scale table */

  if (dd->dsp_id == DISPID_OLED96X64X16) {
    dd->height            = 64;
    dd->depth             = 16;
    dd->colour_spaces     = SD_CS_SELFEMITTING | SD_CS_BGR | SD_CS_RGB565 | SD_CS_RGB332;
    dd->min_contrast      = 0;
    dd->max_contrast      = 0x0F;  
    dd->dsparea_width     = 20100;     /* according to datasheet */
    dd->dsparea_height    = 13400;

    dd->fp_update         = &serdisp_oledcolour_cc_update;
    dd->optalgo_maxdelta  = 6;
  } else if (dd->dsp_id == DISPID_OLED128X64X4) {
    dd->width             = 128;
    dd->height            = 64;
    dd->depth             = 4;
    dd->colour_spaces     = SD_CS_SELFEMITTING | SD_CS_GREYSCALE;
    dd->min_contrast      = 0x00; /*0x10; */
    dd->max_contrast      = 0x7F; /*0x3F; */
    dd->dsparea_width     = 61400;     /* according to datasheet */
    dd->dsparea_height    = 30700;

    dd->fp_update         = &serdisp_oled128x64x4_update;
#ifdef SD_SUPP_ARCHINDEP_SDCOL_FUNCTIONS
    dd->fp_setsdpixel     = &sdtools_generic_setsdpixel_greyhoriz;
    dd->fp_getsdpixel     = &sdtools_generic_getsdpixel_greyhoriz;
#else
    dd->fp_setpixel       = &sdtools_generic_setpixel_greyhoriz;
    dd->fp_getpixel       = &sdtools_generic_getpixel_greyhoriz;
#endif
    dd->optalgo_maxdelta  = 6;
  } else if (dd->dsp_id == DISPID_BL160128A) {
    dd->width             = 160;
    dd->height            = 128;
    dd->depth             = 18;
    dd->colour_spaces     = SD_CS_SELFEMITTING | SD_CS_RGB565 | SD_CS_RGB332 | SD_CS_RGB666;
    dd->min_contrast      = 0;
    dd->max_contrast      = 0x0F;
    dd->dsparea_width     = 37015;     /* according to datasheet */
    dd->dsparea_height    = 30012;

    dd->fp_clear          = &serdisp_ssdoled_clear;
    dd->fp_update         = &serdisp_oledcolour_cd_update;
    dd->optalgo_maxdelta  = 6;

    serdisp_ssdoled_internal_getStruct(dd)->gstablecorr = 200; /* contrast too high with default 100 */
  } else if (dd->dsp_id == DISPID_4DOLED282815) {
    dd->width             = 128;
    dd->height            = 128;
    dd->depth             = 18;
    dd->startycol         = 4;   /* first line on display: 4 */
    dd->colour_spaces     = SD_CS_SELFEMITTING | SD_CS_RGB565 | SD_CS_RGB332 | SD_CS_RGB666;
    dd->min_contrast      = 0x00;
    dd->max_contrast      = 0x0F;

    dd->fp_clear          = &serdisp_ssdoled_clear;
    dd->fp_update         = &serdisp_oledcolour_cd_update;
    dd->optalgo_maxdelta  = 6;

    serdisp_ssdoled_internal_getStruct(dd)->gstablecorr = 200; /* contrast too high with default 100 */
  }

  serdisp_ssdoled_internal_getStruct(dd)->interfacemode = INTERFACE_8080;
  serdisp_ssdoled_internal_getStruct(dd)->sloppysignal =  0; /* stay on the safe side per default */

  /* finally set some non display specific defaults */

  dd->curr_rotate       = 0;         /* unrotated display */
  dd->curr_invert       = 0;         /* display not inverted */

  /* supported output devices */
  dd->connection_types  = SERDISPCONNTYPE_PARPORT;

  if (dd->dsp_id == DISPID_OLED96X64X16) {
    serdisp_setupstructinfos(dd, serdisp_ssdoled_wiresignals, serdisp_ssdoled_wiredefs, serdisp_oled96x64x16_options);
  } else if (dd->dsp_id == DISPID_OLED128X64X4) {
    serdisp_setupstructinfos(dd, serdisp_ssdoled_wiresignals, serdisp_ssdoled_wiredefs, serdisp_oled128x64x4_options);
  } else if (dd->dsp_id == DISPID_BL160128A) {
    serdisp_setupstructinfos(dd, serdisp_ssdoled_wiresignals, serdisp_ssdoled_wiredefs, serdisp_bl160128a_options);
  } else if (dd->dsp_id == DISPID_4DOLED282815) {
    serdisp_setupstructinfos(dd, serdisp_ssdoled_wiresignals, serdisp_ssdoled_wiredefs, serdisp_4doled282815_options);
  } else {
    serdisp_setupstructinfos(dd, serdisp_ssdoled_wiresignals, serdisp_ssdoled_wiredefs, serdisp_ssdoled_options);
  }

  /* parse and set options */
  if (serdisp_setupoptions(dd, dispname, optionstring) ) {
    free(dd->specific_data);
    free(dd);
    dd = 0;
    return (serdisp_t*)0;
  }

  if (dd->dsp_id == DISPID_BL160128A || dd->dsp_id == DISPID_4DOLED282815) {
    if ( ! (dd->depth == 8 || dd->depth == 16 || dd->depth == 18) ) {
      sd_error(SERDISP_ENOTSUP, "%s(): display depth %d not supported (supported depths are: 8, 16, 18)", __func__, dd->depth);
      free(dd->specific_data);
      free(dd);
      dd = 0;
      return (serdisp_t*)0;
    }
  }

  return dd;
}
Ejemplo n.º 4
0
extern int log4c_init(void)
{    
    size_t i;
    int ret = 0;
  
    sd_debug("log4c_init[");
  
    /* activate GLIBC allocation debugging */
#if defined(__LOG4C_DEBUG__) && defined(__GLIBC__)
    mtrace();
#endif
  
    if (log4c_is_init){
	sd_debug("log4c already initialized ]");
	return 0;
    }
  
    log4c_is_init++;
  
    /* Initialize default types: layouts, appenders, rollingpolicies */
    sd_debug("intializing default types: appenders, layouts, rollingpolicies");
    for (i = 0; i < nlayout_types; i++) 
	log4c_layout_type_set(layout_types[i]);
  
    for (i = 0; i < nappender_types; i++) 
	log4c_appender_type_set(appender_types[i]);
#ifdef WITH_ROLLINGFILE
    for (i = 0; i < nrollingpolicy_types; i++) 
	log4c_rollingpolicy_type_set(rollingpolicy_types[i]);
#endif
  
    /* load configuration files */
    {
	int i;
	sd_debug("looking for conf files...");
	snprintf(rcfiles[0].name, sizeof(rcfiles[0].name) - 1, "%s/log4crc", 
		 getenv("LOG4C_RCPATH") ? getenv("LOG4C_RCPATH") : LOG4C_RCPATH);
	snprintf(rcfiles[1].name, sizeof(rcfiles[1].name) - 1, "%s/.log4crc",
		 getenv("HOME") ? getenv("HOME") : "");
    
	for (i = 0; i < nrcfiles; i++) {
	    sd_debug("checking for conf file at '%s'", rcfiles[i].name);
	    if (SD_ACCESS_READ(rcfiles[i].name)) continue;
	    if (SD_STAT_CTIME(rcfiles[i].name,&rcfiles[i].ctime) != 0)
		sd_error("sd_stat_ctime %s failed", rcfiles[i].name);
	    rcfiles[i].exists=1;
	    if (log4c_load(rcfiles[i].name) == -1) {
		sd_error("loading %s failed", rcfiles[i].name);
		ret = -1;
	    }
	    else
		sd_debug("loading %s succeeded", rcfiles[i].name);		
	}
    }
  
    /* override configuration with environment variables */
    {
	const char* priority;
	const char* appender;
    
	sd_debug("checking environment variables...");
	if ( (priority = getenv("LOG4C_PRIORITY")) != NULL){
	    sd_debug("setting priority of root category to '%s'",
		     priority);
	    log4c_category_set_priority(log4c_category_get("root"), 
					log4c_priority_to_int(priority)); 
	}
    
	if ( (appender = getenv("LOG4C_APPENDER")) != NULL){
	    sd_debug("setting appender of root category to '%s'",
		     appender);
	    log4c_category_set_appender(log4c_category_get("root"), 
					log4c_appender_get(appender));
	}
    }
  
    /*
     *   For debug dump current types and instances:
     *   this allows the caller of log4c_init() to see:
     *   1. all types currently registered, including perhaps his own.
     *   2. all instances instantiated via the configuration file.
     *   
     *   If the caller goes on to programmatically create instaces then he
     *   can call log4c_dump_all_instances() later himself to
     *   verify that they were created as expected.
     *  
     */    
#ifdef __SD_DEBUG__
    if( getenv("SD_DEBUG")){
	log4c_dump_all_types(stderr);
	log4c_dump_all_instances(stderr);
    }
#endif
  
  
    sd_debug("]");
    return ret;
}
Ejemplo n.º 5
0
/* *********************************
   serdisp_t* serdisp_t6963_setup(sdcd, dispname, optionstring)
   *********************************
   sets up a display descriptor fitting to dispname and extra
   *********************************
   sdcd             ... output device handle (not used in here)
   dispname         ... display name (case-insensitive)
   optionstring     ... option string containing individual options
   *********************************
   returns a display descriptor
*/
serdisp_t* serdisp_t6963_setup(const serdisp_CONN_t* sdcd, const char* dispname, const char* optionstring) {
  serdisp_t* dd;
  int scrbuf_columns;

  if (! (dd = (serdisp_t*)sdtools_malloc(sizeof(serdisp_t)) ) ) {
    sd_error(SERDISP_EMALLOC, "serdisp_t6963_setup(): cannot allocate display descriptor");
    return (serdisp_t*)0;
  }
  memset(dd, 0, sizeof(serdisp_t));

  if (! (dd->specific_data = (void*) sdtools_malloc( sizeof(serdisp_t6963_specific_t)) )) {
    free(dd);
    return (serdisp_t*)0;
  }

  memset(dd->specific_data, 0, sizeof(serdisp_t6963_specific_t));

  /* "T6963"-based displays supported in here */
  /* assign dd->dsp_id */
  if (serdisp_comparedispnames("T6963", dispname))
    dd->dsp_id = DISPID_T6963;
  else if (serdisp_comparedispnames("TLX1391", dispname))
    dd->dsp_id = DISPID_TLX1391;
  else if (serdisp_comparedispnames("T6963SERMOD", dispname))
    dd->dsp_id = DISPID_T6963SERMOD;
  else {  /* should not occur */
    sd_error(SERDISP_ENOTSUP, "display '%s' not supported by serdisp_specific_t6963.c", dispname);
    return (serdisp_t*)0;
  }

  dd->width             = 240;
  dd->height            = 128;
  dd->depth             = 1;
  dd->colour_spaces     = SD_CS_SCRBUFCUSTOM | SD_CS_GREYSCALE;
  dd->feature_contrast  = 0;
  dd->feature_invert    = 0;
  dd->curr_backlight    = 1;         /* start with backlight on */

  /* max. delta for optimised update algorithm */
  dd->optalgo_maxdelta  = 4;

  /* default: fontwidth = 8 */
  dd->scrbuf_bits_used = 8;

  serdisp_t6963_internal_getStruct(dd)->checkstatus = 0;

  /* finally set some non display specific defaults */

  dd->curr_rotate       = 0;         /* unrotated display */
  dd->curr_invert       = 0;         /* display not inverted */

  /* supported output devices */
  dd->connection_types  = SERDISPCONNTYPE_PARPORT;

  /* default interface mode */
  serdisp_t6963_internal_getStruct(dd)->interfacemode = INTERFACE_PARALLEL;

  dd->fp_init           = &serdisp_t6963_init;
  dd->fp_update         = &serdisp_t6963_update;
  dd->fp_close          = &serdisp_t6963_close;
  dd->fp_setoption      = &serdisp_t6963_setoption;

#ifdef SD_SUPP_ARCHINDEP_SDCOL_FUNCTIONS
  dd->fp_setsdpixel     = &sdtools_generic_setsdpixel_greyhoriz;
  dd->fp_getsdpixel     = &sdtools_generic_getsdpixel_greyhoriz;
#else
  dd->fp_setpixel       = &sdtools_generic_setpixel_greyhoriz;
  dd->fp_getpixel       = &sdtools_generic_getpixel_greyhoriz;
#endif

  dd->fp_getvalueptr    = &serdisp_t6963_getvalueptr;

  dd->delay = -1;

  serdisp_setupstructinfos(dd, serdisp_t6963_wiresignals, serdisp_t6963_wiredefs, serdisp_t6963_options);

  /* parse and set options */
  if (serdisp_setupoptions(dd, dispname, optionstring) ) {
    free(dd->specific_data);
    free(dd);
    dd = 0;
    return (serdisp_t*)0;    
  }

  /* no status check when serial mode */
  if ( serdisp_t6963_internal_getStruct(dd)->interfacemode == INTERFACE_SERIAL) {
    serdisp_t6963_internal_getStruct(dd)->checkstatus = 0;
  }

  /* if status should not be checked AND delay not set  -> set delay to 100 */
  if ( (serdisp_t6963_internal_getStruct(dd)->checkstatus == 0) && (dd->delay == -1)) {
    dd->delay = 100;
  }
  /* status check AND delay not set -> set delay to 0 */
  if (dd->delay == -1)
    dd->delay = 0;

  scrbuf_columns = (dd->width + dd->xcolgaps + dd->scrbuf_bits_used - 1) / dd->scrbuf_bits_used;

  /* calculate (non default) screen buffer size */
  dd->scrbuf_size = sizeof(byte) * (scrbuf_columns * ( dd->height +dd->ycolgaps )); 

  /* one byte is able to store 8 change infos */
  dd->scrbuf_chg_size = sizeof(byte) * ( ((int)((scrbuf_columns + 7)/8)) * ( dd->height +dd->ycolgaps ));

  return dd;
}
Ejemplo n.º 6
0
/* *********************************
   serdisp_t* serdisp_directgfx_setup(sdcd, dispname, optionstring)
   *********************************
   sets up a display descriptor fitting to dispname and extra
   *********************************
   sdcd             ... output device handle
   dispname         ... display name (case-insensitive)
   optionstring     ... option string containing individual options
   *********************************
   returns a display descriptor
*/
serdisp_t* serdisp_directgfx_setup(const serdisp_CONN_t* sdcd, const char* dispname, const char* optionstring) {
  serdisp_t* dd;

  if ( ! SDFCTPTR_checkavail(SDFCTPTR_LIBSDL) ) {
    sd_error(SERDISP_ERUNTIME, "%s(): libSDL is not loaded.", __func__);
    return (serdisp_t*)0;
  }

  if (! (dd = (serdisp_t*)sdtools_malloc(sizeof(serdisp_t)) ) ) {
    sd_error(SERDISP_EMALLOC, "%s(): cannot allocate display descriptor", __func__);
    return (serdisp_t*)0;
  }
  memset(dd, 0, sizeof(serdisp_t));

  if (! (dd->specific_data = (void*) sdtools_malloc( sizeof(serdisp_directgfx_specific_t)) )) {
    free(dd);
    return (serdisp_t*)0;
  }
  memset(dd->specific_data, 0, sizeof(serdisp_directgfx_specific_t));

  /* output devices like SDL supported here */
  /* assign dd->dsp_id */
  if (serdisp_comparedispnames("SDL", dispname))
    dd->dsp_id = DISPID_SDL;
  else {  /* should not occur */
    sd_error(SERDISP_ENOTSUP, "display '%s' not supported by serdisp_specific_directgfx.c", dispname);
    return (serdisp_t*)0;
  }

  dd->sdcd = (serdisp_CONN_t*)sdcd;

  /* supported output devices */
  dd->connection_types  = SERDISPCONNTYPE_OUT;


  serdisp_directgfx_internal_getStruct(dd)->fullscreen = 1;

  dd->feature_contrast  = 0;
  dd->feature_backlight = 0;
  dd->feature_invert    = 0;

  /* per display settings */

  dd->width             = 320;
  dd->height            = 240;
  dd->depth             = 32;

  /* max. delta for optimised update algorithm */
  dd->optalgo_maxdelta  = 0;  /* unused, bbox is used for optimisation */

  dd->delay = 0;

  /* finally set some non display specific defaults */

  dd->curr_rotate       = 0;         /* unrotated display */
  dd->curr_invert       = 0;         /* display not inverted */

  dd->curr_backlight    = 0;         /* start with backlight on */

  /* supported colour spaces */
  dd->colour_spaces     = SD_CS_GREYSCALE | SD_CS_RGB332 | SD_CS_RGB444 | SD_CS_RGB565;
  dd->colour_spaces    |= SD_CS_TRUECOLOUR | SD_CS_ATRUECOLOUR;
  dd->colour_spaces    |= SD_CS_SELFEMITTING;

  dd->fp_init           = &serdisp_directgfx_init;
  dd->fp_update         = &serdisp_directgfx_update;
/*  dd->fp_clear          = &serdisp_directgfx_clear;*/
  dd->fp_close          = &serdisp_directgfx_close;
  dd->fp_setoption      = &serdisp_directgfx_setoption;
  dd->fp_getvalueptr    = &serdisp_directgfx_getvalueptr;

  serdisp_setupstructinfos(dd, 0, 0, serdisp_directgfx_options);

  /* parse and set options */
  if (serdisp_setupoptions(dd, dispname, optionstring) ) {
    serdisp_freeresources(dd);
    dd = 0;
    return (serdisp_t*)0;
  }

  return dd;
}