Skip to content

Commit

Permalink
Implement power level option
Browse files Browse the repository at this point in the history
Closes #7
  • Loading branch information
ali1234 committed Sep 6, 2019
1 parent 6e5cecf commit 18fe7b8
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 9 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,19 @@ registers are in a known state before doing anything. "on" and
"off" commands will have no effect if the state is already on or
off, or if the registers are in an unknown state.

teletext [-m even field line mask] [-o odd field line mask] [-]
teletext [-m even field line mask] [-o odd field line mask] \
[-l white level] [-]

Optional line mask arguments are a 16 bit mask to create quiet lines
in vbi output, first line is LSB, last is MSB. For example running
"teletext -m 0xFFF0 -o 0x0FFF" will output teletext packets on the first four lines of even fields and last four lines of odd fields. If only one mask is provided the same value will be used for both fields.
"teletext -m 0xFFF0 -o 0x0FFF" will output teletext packets on the
first four lines of even fields and last four lines of odd fields.
If only one mask is provided the same value will be used for both
fields.

The white level is specified as a number between 0 and 100. This
is the "brightness" of the high bits of the teletext signal.
Default is 100.

Running with no arguments will show a demo. Running "teletext -"
will read packets from stdin and display them. You can therefore
Expand Down
16 changes: 15 additions & 1 deletion cea608.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,21 @@ void init(uint8_t *image)

int main(int argc, char *argv[])
{
void *render_handle = render_start(WIDTH, HEIGHT, OFFSET, FIXED, init, draw, -1);
int c, level = 100;

while ((c = getopt(argc,argv,"l:")) != -1)
{
switch(c)
{
case 'l':
level = strtol(optarg,NULL,0);
if (level < 0) level == 0;
if (level > 100) level == 100;
break;
}
}

void *render_handle = render_start(WIDTH, HEIGHT, OFFSET, FIXED, init, draw, -1, level);

if (argc >= 2 && strlen(argv[argc-1])==1 && argv[argc-1][0] == '-') { // last argument is a single '-'
while(read_packets()) {
Expand Down
8 changes: 6 additions & 2 deletions render.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,19 @@ void vsync_callback(DISPMANX_UPDATE_HANDLE_T u, void *anon_render_shared)
}


void *render_start(int width, int height, int offset, int fixed, InitFunc init_func, DrawFunc draw_func, int delay)
void *render_start(int width, int height, int offset, int fixed, InitFunc init_func, DrawFunc draw_func, int delay, int level)
{
int ret;

level = (int)((level * 31) / 100.0);
int white = 0x0020 | level | level << 6 | level << 11;

VC_RECT_T src_rect;
VC_RECT_T dst_rect;

DISPMANX_UPDATE_HANDLE_T update;
uint32_t vc_image_ptr;
unsigned short palette[256] = { 0x0, 0xffff, 0xf000 };
unsigned short palette[256] = { 0x0, white, 0xf000 };

// Build the render struct. Must malloc it so it is still valid
// after this function returns.
Expand Down
2 changes: 1 addition & 1 deletion render.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
typedef void (*InitFunc)(uint8_t *image);
typedef void (*DrawFunc)(uint8_t *image, int next_resource);

void *render_start(int width, int height, int offset, int fixed, InitFunc init_func, DrawFunc draw_func, int delay);
void *render_start(int width, int height, int offset, int fixed, InitFunc init_func, DrawFunc draw_func, int delay, int level);
void render_stop(void *);
11 changes: 8 additions & 3 deletions teletext.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ void init(uint8_t *image)

int main(int argc, char *argv[])
{
int c;
int c, level = 100;
char *mvalue = NULL;
char *ovalue = NULL;
while ((c = getopt(argc,argv,"m:o:")) != -1)
while ((c = getopt(argc,argv,"m:o:l:")) != -1)
{
switch(c)
{
Expand All @@ -87,6 +87,11 @@ int main(int argc, char *argv[])
case 'o':
ovalue = optarg;
break;
case 'l':
level = strtol(optarg,NULL,0);
if (level < 0) level == 0;
if (level > 100) level == 100;
break;
}
}

Expand All @@ -106,7 +111,7 @@ int main(int argc, char *argv[])
line_mask[0] = line_mask[1];
}

void *render_handle = render_start(WIDTH, HEIGHT, OFFSET, FIXED, init, draw, -1);
void *render_handle = render_start(WIDTH, HEIGHT, OFFSET, FIXED, init, draw, -1, level);

if (argc >= 2 && strlen(argv[argc-1])==1 && argv[argc-1][0] == '-') { // last argument is a single '-'
while(read_packets()) {
Expand Down

0 comments on commit 18fe7b8

Please sign in to comment.