This commit is contained in:
olikraus 2015-12-25 16:42:45 +01:00
parent 7c73ac3202
commit d062ba07de
4 changed files with 129 additions and 3 deletions

View File

@ -61,6 +61,9 @@ class U8G2 : public Print
void firstPage(void) { u8g2_FirstPage(&u8g2); }
uint8_t nextPage(void) { return u8g2_NextPage(&u8g2); }
void sendBuffer(void) { u8g2_SendBuffer(&u8g2); }
void clearBuffer(void) { u8g2_ClearBuffer(&u8g2); }
void setFont(const uint8_t *font) {u8g2_SetFont(&u8g2, font); }

View File

@ -16,7 +16,7 @@ U8glib V2: Features and Limitations
- Compilation speed improved (font data)
- "Text only" sub library
- "Text only" sub library: U8x8
- less RAM/ROM usage

View File

@ -488,13 +488,13 @@ void do_md_display(int controller_idx, int display_idx)
fprintf(fp, "| Controller \"%s\", ", controller_list[controller_idx].name);
fprintf(fp, "Display \"%s\" | ", controller_list[controller_idx].display_list[display_idx].name);
fprintf(fp, "Descirption |\n");
fprintf(fp, "|--|--|\n");
fprintf(fp, "|---|---|\n");
}
else
{
fprintf(fp, "| Controller \"%s\", ", controller_list[controller_idx].name);
fprintf(fp, "Display \"%s\" |\n", controller_list[controller_idx].display_list[display_idx].name);
fprintf(fp, "|--|\n");
fprintf(fp, "|---|\n");
}
}
@ -717,6 +717,10 @@ int main(void)
insert_into_file("../../cppsrc/U8g2lib.h", "U8g2lib.h", "/* Arduino constructor list start */", "/* Arduino constructor list end */");
insert_into_file("../../cppsrc/U8x8lib.h", "U8x8lib.h", "// constructor list start", "// constructor list end");
insert_into_file("../../../u8g2.wiki/u8g2setupc.md", "u8g2setupc.md", "# Reference", "# Links");
insert_into_file("../../../u8g2.wiki/u8g2setupcpp.md", "u8g2setupcpp.md", "# Reference", "# Links");
insert_into_file("../../../u8g2.wiki/u8x8setupc.md", "u8x8setupc.md", "# Reference", "# Links");
insert_into_file("../../../u8g2.wiki/u8x8setupcpp.md", "u8x8setupcpp.md", "# Reference", "# Links");
return 0;

119
tools/mdtoc/mdtoc.c Normal file
View File

@ -0,0 +1,119 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define TOC_ENTRIES 512
#define TOC_ENTRY_SIZE 1024
char toc_start[] = "[tocstart]: # (toc start)";
char toc_end[] = "[tocend]: # (toc end)";
char toc[TOC_ENTRIES][TOC_ENTRY_SIZE];
int toc_level[TOC_ENTRIES];
int toc_cnt = 0;
void add_toc(int level, char *entry)
{
strncpy( toc[toc_cnt], entry, TOC_ENTRY_SIZE);
toc[toc_cnt][TOC_ENTRY_SIZE-1] = '\0';
toc_level[toc_cnt] = level;
toc_cnt++;
printf("%d: %s\n", level, entry);
}
void read_md_fp(FILE *in, FILE *out)
{
static char buf[TOC_ENTRY_SIZE];
char *s;
int is_inside_toc = 0;
int is_start_of_file = 1;
for(;;)
{
s = fgets(buf, TOC_ENTRY_SIZE, in);
if ( s == NULL )
return;
if ( is_inside_toc != 0 )
{
if ( strcmp(s, toc_end) == 0 )
{
is_inside_toc = 0;
}
}
else
{
if ( buf[0] == '\0' )
{
/* skip empty lines at the beginning of the file */
if ( is_start_of_file == 0 )
fputs(buf, out);
}
else if ( strcmp(s, toc_start) == 0 )
{
is_start_of_file = 0;
is_inside_toc = 1;
}
else if ( strncmp(s, "# ", 2) == 0 )
{
is_start_of_file = 0;
add_toc(1, s+2);
fputs(buf, out);
}
else if ( strncmp(s, "## ", 3) == 0 )
{
is_start_of_file = 0;
add_toc(2, s+3);
fputs(buf, out);
}
else
{
is_start_of_file = 0;
fputs(buf, out);
}
}
}
}
void read_md(const char *in_name, const char *out_name)
{
FILE *in;
FILE *out;
in = fopen(in_name, "r");
if ( in == NULL )
{
perror(in_name);
return;
}
out = fopen(out_name, "w");
if ( out == NULL )
{
perror(out_name);
return;
}
read_md_fp(in, out);
fclose(in);
fclose(out);
}
int main(int argc, char **argv)
{
if ( argc <= 1 )
{
printf("%s [markdown files]\n", argv[0]);
return 1;
}
argv++;
while( *argv != NULL )
{
toc_cnt = 0;
read_md(*argv, "tmp.md");
argv++;
}
}