int main(void) { InitHardware(); dmInit(); sei(); // enable interrupts GoToSleep(); button |= PB_ACK; while(1) { if (button == PB_RELEASE) { // short button press msg_ptr = DisplayMessage(msg_ptr); button |= PB_ACK; } if (button == PB_LONGPRESS) { // button pressed for some seconds dmClearDisplay(); dmPrintChar(130); // sad smiley _delay_ms(500); GoToSleep(); button |= PB_ACK; } } // of while(1) }
void BMP2DotMatrix(_TCHAR* bmp, _TCHAR* op, _TCHAR* hex, _TCHAR* variation) { PALLET pal; DOTMATRIX dm, odm; DOTMATRIX* font; DOTMATRIXPOT start, corner, end; FONTSIZE fs; FILE* fp; wchar_t* stopword; double tolerance = wcstod(variation, &stopword); fs.h = fs.w = 12; if (_wfopen_s(&fp, bmp, L"rb") > 0) { wprintf(L"Can not open file: %s\n", bmp); return; } if (getPallet(&pal, fp) > 0) { printf("Can not read pallet from bmp\n"); return; } thresholding(&pal, &_tchar2RGB(hex), tolerance); dmInit(&pal); if (getMatrix() > 0) { printf("Can not read dot matrix from pallet\n"); return; } freePallet(&pal); fclose(fp); if (_wfopen_s(&fp, op, L"w") > 0) { wprintf(L"Can not open file: %s\n", op); return; } /* start.r = start.c = 0; start = matSanH(&dm, &start); printf("start.r = %d\n", start.r); printf("start.c = %d\n", start.c); corner = matSanV(&dm, &start, &fs); printf("corner.r = %d\n", corner.r); printf("corner.c = %d\n", corner.c); end = reMatSanV(&dm, &start, &fs); */ // matCarve(&corner, &end, &dm, &odm, &fs); // dotmat2File(fp); // matCarveByChar(&odm, font, &fs); freeMatrix(); // freeMatrix(&odm); fclose(fp); printf("Program finished.\n"); }
main(int argc, char *argv[]) { extern int optind; extern char *optarg; char *oldcellname=NULL,newcellname[DM_MAXNAME+1]; char ilist[DM_MAXNOMASKS][1+DM_MAXLAY]; char xlist[DM_MAXNOMASKS][1+DM_MAXLAY]; int c,n_ilist=0,n_xlist=0; DM_PROJECT *projectkey; void flatten_mc(); char filtermc[100]; /* PATRICK: name of dir to be filtered */ strcpy(newcellname,"testflat"); strcpy(filtermc,"/celllibs/"); FilterLib = NULL; while ((c=getopt(argc,argv,"hlL:so:i:x:"))!=EOF) { switch (c) { case 'h': /* print help */ printhelp(argv[0]); exit(0); break; case 'l': /* filter out libraries */ FilterLib = &filtermc[0]; break ; case 'L': /* filter lib */ strcpy(filtermc,optarg); FilterLib = &filtermc[0]; break ; case 's': /* lift all subterminals as well */ liftsubterm = TRUE ; break ; case 'o': /* specifies name of outputcell */ strcpy(newcellname,optarg); break; case 'i': /* specifies a layer to include */ if (n_xlist>0) /* also specified -x option ... */ { fprintf(stderr,"\nERROR: the options -i and -x are mutually exclusive...\n"); printhelp(argv[0]); exit(1); } strncpy(&ilist[n_ilist],optarg,1+DM_MAXLAY); /* store the name of the layer */ ilist[n_ilist++][DM_MAXLAY]='\0'; break; case 'x': /* specifies a layer to exclude */ if (n_ilist>0) /* also specified -i option ... */ { fprintf(stderr,"\nERROR: the options -i and -x are mutually exclusive...\n"); printhelp(argv[0]); exit(1); } strncpy(&xlist[n_xlist],optarg,1+DM_MAXLAY); /* store the name of the layer */ xlist[n_xlist++][DM_MAXLAY]='\0'; break; case '?': fprintf(stderr,"\nillegal option for %s\n\n",argv[0]); exit(1); break; default: break; } } if (optind>=argc) { fprintf(stderr,"ERROR: you must specify a cell name!\n"); printhelp(argv[0]); exit(1); } oldcellname=argv[optind++]; if (optind<argc) { fprintf(stderr,"ERROR: use only one argument!\n"); printhelp(argv[0]); exit(1); } dmInit("layflat"); if ((projectkey=dmOpenProject(DEFAULT_PROJECT,DEFAULT_MODE))==NULL) { fprintf(stderr,"Cannot open project\n"); exit(1); } if ((processinfo = (DM_PROCDATA *) dmGetMetaDesignData(PROCESS, projectkey)) == NULL) { fprintf(stderr,"Cannot read process data\n"); exit(1); } if (initializemasklist(ilist,n_ilist,xlist,n_xlist) == NIL) exit(1); if(FilterLib != NULL) { printf("%s: Not flattening cells of which the library path contains '%s'\n", argv[0], FilterLib); } printf("%s: flat layout goes into cell '%s'\n", argv[0], newcellname); flatten_mc(newcellname,oldcellname,projectkey); dmCloseProject(projectkey,COMPLETE); dmQuit(); }