summaryrefslogtreecommitdiff
path: root/apps/plugins/pictureflow.c
diff options
context:
space:
mode:
authorAndrew Mahone <andrew.mahone@gmail.com>2009-01-17 07:13:11 +0000
committerAndrew Mahone <andrew.mahone@gmail.com>2009-01-17 07:13:11 +0000
commit313eaf8e3730bf0966560b18d35fc3b53076ce51 (patch)
tree04470acf7b5a272311d20352c5b4a0d251afdc1a /apps/plugins/pictureflow.c
parent56376e6a42b4400f66e22ce40a7807c8d1487952 (diff)
downloadrockbox-313eaf8e3730bf0966560b18d35fc3b53076ce51.tar.gz
rockbox-313eaf8e3730bf0966560b18d35fc3b53076ce51.zip
pictureflow configfile conversion:
settings use configfile from pluginlib cache version is stored in config file, so that changes to the cache file format can trigger rebuild automatically cache version is set to 0 to flag cache as needing rebuild git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19780 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/pictureflow.c')
-rw-r--r--apps/plugins/pictureflow.c204
1 files changed, 86 insertions, 118 deletions
diff --git a/apps/plugins/pictureflow.c b/apps/plugins/pictureflow.c
index 936959ca5b..acae82a2f5 100644
--- a/apps/plugins/pictureflow.c
+++ b/apps/plugins/pictureflow.c
@@ -26,6 +26,7 @@
26#include "plugin.h" 26#include "plugin.h"
27#include "lib/pluginlib_actions.h" 27#include "lib/pluginlib_actions.h"
28#include "lib/helper.h" 28#include "lib/helper.h"
29#include "lib/configfile.h"
29#include "lib/picture.h" 30#include "lib/picture.h"
30#include "pluginbitmaps/pictureflow_logo.h" 31#include "pluginbitmaps/pictureflow_logo.h"
31#include "lib/grey.h" 32#include "lib/grey.h"
@@ -111,9 +112,6 @@ typedef fb_data pix_t;
111 112
112#define MAX_SLIDES_COUNT 10 113#define MAX_SLIDES_COUNT 10
113 114
114#define SPACING_BETWEEN_SLIDE 40
115#define EXTRA_SPACING_FOR_CENTER_SLIDE 0
116
117#define THREAD_STACK_SIZE DEFAULT_STACK_SIZE + 0x200 115#define THREAD_STACK_SIZE DEFAULT_STACK_SIZE + 0x200
118#define CACHE_PREFIX PLUGIN_DEMOS_DIR "/pictureflow" 116#define CACHE_PREFIX PLUGIN_DEMOS_DIR "/pictureflow"
119 117
@@ -132,12 +130,15 @@ typedef fb_data pix_t;
132 130
133#define EMPTY_SLIDE CACHE_PREFIX "/emptyslide.pfraw" 131#define EMPTY_SLIDE CACHE_PREFIX "/emptyslide.pfraw"
134#define EMPTY_SLIDE_BMP PLUGIN_DEMOS_DIR "/pictureflow_emptyslide.bmp" 132#define EMPTY_SLIDE_BMP PLUGIN_DEMOS_DIR "/pictureflow_emptyslide.bmp"
135#define CONFIG_FILE CACHE_PREFIX "/pictureflow.config"
136 133
137/* Error return values */ 134/* Error return values */
138#define ERROR_NO_ALBUMS -1 135#define ERROR_NO_ALBUMS -1
139#define ERROR_BUFFER_FULL -2 136#define ERROR_BUFFER_FULL -2
140 137
138/* current version for cover cache */
139#define CACHE_VERSION 1
140#define CONFIG_VERSION 1
141#define CONFIG_FILE "pictureflow.cfg"
141 142
142/** structs we use */ 143/** structs we use */
143 144
@@ -189,18 +190,41 @@ const struct picture logos[]={
189 190
190enum show_album_name_values { album_name_hide = 0, album_name_bottom , 191enum show_album_name_values { album_name_hide = 0, album_name_bottom ,
191 album_name_top }; 192 album_name_top };
193static char* show_album_name_conf[] =
194{
195 "hide",
196 "bottom",
197 "top"
198};
199
200#define MAX_SPACING 40
201#define MAX_MARGIN 80
202
203/* config values and their defaults */
204static int slide_spacing = (LCD_WIDTH - DISPLAY_WIDTH) / 8;
205static int center_margin = (LCD_WIDTH - DISPLAY_WIDTH) / 16;
206static int num_slides = 4;
207static int zoom = 100;
208static bool show_fps = false;
209static bool resize = true;
210static int cache_version = 0;
211static enum show_album_name_values show_album_name = album_name_top;
192 212
193struct config_data { 213static struct configdata config[] =
194 long avg_album_width; 214{
195 int spacing_between_slides; 215 { TYPE_INT, 0, MAX_SPACING, &slide_spacing, "slide spacing", NULL, NULL },
196 int extra_spacing_for_center_slide; 216 { TYPE_INT, 0, MAX_MARGIN, &center_margin, "center margin", NULL, NULL },
197 int show_slides; 217 { TYPE_INT, 0, MAX_SLIDES_COUNT, &num_slides, "slides count", NULL, NULL },
198 int zoom; 218 { TYPE_INT, 0, 300, &zoom, "zoom", NULL, NULL },
199 bool show_fps; 219 { TYPE_INT, 0, 1, (int *)&show_fps, "show fps", NULL, NULL },
200 bool resize; 220 { TYPE_INT, 0, 1, (int *)&resize, "resize", NULL, NULL },
201 enum show_album_name_values show_album_name; 221 { TYPE_INT, 0, 100, &cache_version, "cache version", NULL, NULL },
222 { TYPE_ENUM, 0, 2, (int *)&show_album_name, "show album name",
223 show_album_name_conf, NULL }
202}; 224};
203 225
226#define CONFIG_NUM_ITEMS (sizeof(config) / sizeof(struct configdata))
227
204/** below we allocate the memory we want to use **/ 228/** below we allocate the memory we want to use **/
205 229
206static pix_t *buffer; /* for now it always points to the lcd framebuffer */ 230static pix_t *buffer; /* for now it always points to the lcd framebuffer */
@@ -251,7 +275,6 @@ void reset_track_list(void);
251 275
252void * plugin_buf; 276void * plugin_buf;
253size_t plugin_buf_size; 277size_t plugin_buf_size;
254static struct config_data config;
255 278
256static int old_drawmode; 279static int old_drawmode;
257 280
@@ -595,21 +618,19 @@ void draw_progressbar(int step)
595/** 618/**
596 Precomupte the album art images and store them in CACHE_PREFIX. 619 Precomupte the album art images and store them in CACHE_PREFIX.
597 */ 620 */
598bool create_albumart_cache(bool force) 621bool create_albumart_cache(void)
599{ 622{
600 number_of_slides = album_count;
601 int fh,ret; 623 int fh,ret;
602 624
603 if ( ! force && rb->file_exists( CACHE_PREFIX "/ready" ) ) return true;
604
605 int i, slides = 0; 625 int i, slides = 0;
606 struct bitmap input_bmp; 626 struct bitmap input_bmp;
607 627
608 config.avg_album_width = 0;
609 char pfraw_file[MAX_PATH]; 628 char pfraw_file[MAX_PATH];
610 char albumart_file[MAX_PATH]; 629 char albumart_file[MAX_PATH];
611 unsigned int format = FORMAT_NATIVE; 630 unsigned int format = FORMAT_NATIVE;
612 if (config.resize) 631 cache_version = 0;
632 configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION);
633 if (resize)
613 format |= FORMAT_RESIZE|FORMAT_KEEP_ASPECT; 634 format |= FORMAT_RESIZE|FORMAT_KEEP_ASPECT;
614 for (i=0; i < album_count; i++) 635 for (i=0; i < album_count; i++)
615 { 636 {
@@ -635,7 +656,6 @@ bool create_albumart_cache(bool force)
635 { 656 {
636 rb->splash(HZ, "Could not write bmp"); 657 rb->splash(HZ, "Could not write bmp");
637 } 658 }
638 config.avg_album_width += input_bmp.width;
639 slides++; 659 slides++;
640 if ( rb->button_get(false) == PICTUREFLOW_MENU ) return false; 660 if ( rb->button_get(false) == PICTUREFLOW_MENU ) return false;
641 } 661 }
@@ -644,12 +664,8 @@ bool create_albumart_cache(bool force)
644 rb->splash(2*HZ, "No album art found"); 664 rb->splash(2*HZ, "No album art found");
645 return false; 665 return false;
646 } 666 }
647 config.avg_album_width /= slides; 667 cache_version = CACHE_VERSION;
648 if ( config.avg_album_width == 0 ) { 668 configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION);
649 rb->splash(HZ, "album size is 0");
650 return false;
651 }
652 fh = rb->creat( CACHE_PREFIX "/ready" );
653 rb->close(fh); 669 rb->close(fh);
654 return true; 670 return true;
655} 671}
@@ -1012,19 +1028,19 @@ void reset_slides(void)
1012 center_slide.slide_index = center_index; 1028 center_slide.slide_index = center_index;
1013 1029
1014 int i; 1030 int i;
1015 for (i = 0; i < config.show_slides; i++) { 1031 for (i = 0; i < num_slides; i++) {
1016 struct slide_data *si = &left_slides[i]; 1032 struct slide_data *si = &left_slides[i];
1017 si->angle = itilt; 1033 si->angle = itilt;
1018 si->cx = -(offsetX + config.spacing_between_slides * i * PFREAL_ONE); 1034 si->cx = -(offsetX + slide_spacing * i * PFREAL_ONE);
1019 si->cy = offsetY; 1035 si->cy = offsetY;
1020 si->slide_index = center_index - 1 - i; 1036 si->slide_index = center_index - 1 - i;
1021 si->distance = 0; 1037 si->distance = 0;
1022 } 1038 }
1023 1039
1024 for (i = 0; i < config.show_slides; i++) { 1040 for (i = 0; i < num_slides; i++) {
1025 struct slide_data *si = &right_slides[i]; 1041 struct slide_data *si = &right_slides[i];
1026 si->angle = -itilt; 1042 si->angle = -itilt;
1027 si->cx = offsetX + config.spacing_between_slides * i * PFREAL_ONE; 1043 si->cx = offsetX + slide_spacing * i * PFREAL_ONE;
1028 si->cy = offsetY; 1044 si->cy = offsetY;
1029 si->slide_index = center_index + 1 + i; 1045 si->slide_index = center_index + 1 + i;
1030 si->distance = 0; 1046 si->distance = 0;
@@ -1051,7 +1067,7 @@ void recalc_table(void)
1051 1067
1052 offsetX = DISPLAY_WIDTH / 2 * (fsin(itilt) + PFREAL_ONE); 1068 offsetX = DISPLAY_WIDTH / 2 * (fsin(itilt) + PFREAL_ONE);
1053 offsetY = DISPLAY_WIDTH / 2 * (fsin(itilt) + PFREAL_ONE / 2); 1069 offsetY = DISPLAY_WIDTH / 2 * (fsin(itilt) + PFREAL_ONE / 2);
1054 offsetX += config.extra_spacing_for_center_slide << PFREAL_SHIFT; 1070 offsetX += center_margin << PFREAL_SHIFT;
1055} 1071}
1056 1072
1057 1073
@@ -1105,7 +1121,7 @@ void render_slide(struct slide_data *slide, const int alpha)
1105 const int w = LCD_WIDTH; 1121 const int w = LCD_WIDTH;
1106 1122
1107 1123
1108 int distance = (h + slide->distance) * 100 / config.zoom; 1124 int distance = (h + slide->distance) * 100 / zoom;
1109 PFreal dist = distance * PFREAL_ONE; 1125 PFreal dist = distance * PFREAL_ONE;
1110 if (distance < 100 ) distance = 100; /* clamp distances */ 1126 if (distance < 100 ) distance = 100; /* clamp distances */
1111 PFreal sdx = fcos(slide->angle); 1127 PFreal sdx = fcos(slide->angle);
@@ -1294,8 +1310,8 @@ void render_all_slides(void)
1294 /* TODO: Optimizes this by e.g. invalidating rects */ 1310 /* TODO: Optimizes this by e.g. invalidating rects */
1295 MYLCD(clear_display)(); 1311 MYLCD(clear_display)();
1296 1312
1297 int nleft = config.show_slides; 1313 int nleft = num_slides;
1298 int nright = config.show_slides; 1314 int nright = num_slides;
1299 1315
1300 int index; 1316 int index;
1301 if (step == 0) { 1317 if (step == 0) {
@@ -1381,9 +1397,9 @@ void update_scroll_animation(void)
1381 center_index = index; 1397 center_index = index;
1382 slide_frame = index << 16; 1398 slide_frame = index << 16;
1383 center_slide.slide_index = center_index; 1399 center_slide.slide_index = center_index;
1384 for (i = 0; i < config.show_slides; i++) 1400 for (i = 0; i < num_slides; i++)
1385 left_slides[i].slide_index = center_index - 1 - i; 1401 left_slides[i].slide_index = center_index - 1 - i;
1386 for (i = 0; i < config.show_slides; i++) 1402 for (i = 0; i < num_slides; i++)
1387 right_slides[i].slide_index = center_index + 1 + i; 1403 right_slides[i].slide_index = center_index + 1 + i;
1388 } 1404 }
1389 1405
@@ -1399,21 +1415,21 @@ void update_scroll_animation(void)
1399 return; 1415 return;
1400 } 1416 }
1401 1417
1402 for (i = 0; i < config.show_slides; i++) { 1418 for (i = 0; i < num_slides; i++) {
1403 struct slide_data *si = &left_slides[i]; 1419 struct slide_data *si = &left_slides[i];
1404 si->angle = itilt; 1420 si->angle = itilt;
1405 si->cx = 1421 si->cx =
1406 -(offsetX + config.spacing_between_slides * i * PFREAL_ONE + step 1422 -(offsetX + slide_spacing * i * PFREAL_ONE + step
1407 * config.spacing_between_slides * ftick); 1423 * slide_spacing * ftick);
1408 si->cy = offsetY; 1424 si->cy = offsetY;
1409 } 1425 }
1410 1426
1411 for (i = 0; i < config.show_slides; i++) { 1427 for (i = 0; i < num_slides; i++) {
1412 struct slide_data *si = &right_slides[i]; 1428 struct slide_data *si = &right_slides[i];
1413 si->angle = -itilt; 1429 si->angle = -itilt;
1414 si->cx = 1430 si->cx =
1415 offsetX + config.spacing_between_slides * i * PFREAL_ONE - step 1431 offsetX + slide_spacing * i * PFREAL_ONE - step
1416 * config.spacing_between_slides * ftick; 1432 * slide_spacing * ftick;
1417 si->cy = offsetY; 1433 si->cy = offsetY;
1418 } 1434 }
1419 1435
@@ -1492,13 +1508,13 @@ int create_empty_slide(bool force)
1492*/ 1508*/
1493int album_name_menu(void) 1509int album_name_menu(void)
1494{ 1510{
1495 int selection = config.show_album_name; 1511 int selection = show_album_name;
1496 1512
1497 MENUITEM_STRINGLIST(album_name_menu,"Show album title",NULL, 1513 MENUITEM_STRINGLIST(album_name_menu,"Show album title",NULL,
1498 "Hide album title", "Show at the bottom", "Show at the top"); 1514 "Hide album title", "Show at the bottom", "Show at the top");
1499 rb->do_menu(&album_name_menu, &selection, NULL, false); 1515 rb->do_menu(&album_name_menu, &selection, NULL, false);
1500 1516
1501 config.show_album_name = selection; 1517 show_album_name = selection;
1502 return GO_TO_PREVIOUS; 1518 return GO_TO_PREVIOUS;
1503} 1519}
1504 1520
@@ -1518,13 +1534,13 @@ int settings_menu(void)
1518 selection=rb->do_menu(&settings_menu,&selection, NULL, false); 1534 selection=rb->do_menu(&settings_menu,&selection, NULL, false);
1519 switch(selection) { 1535 switch(selection) {
1520 case 0: 1536 case 0:
1521 rb->set_bool("Show FPS", &(config.show_fps)); 1537 rb->set_bool("Show FPS", &(show_fps));
1522 reset_track_list(); 1538 reset_track_list();
1523 break; 1539 break;
1524 1540
1525 case 1: 1541 case 1:
1526 rb->set_int("Spacing between slides", "", 1, 1542 rb->set_int("Spacing between slides", "", 1,
1527 &(config.spacing_between_slides), 1543 &slide_spacing,
1528 NULL, 1, 0, 100, NULL ); 1544 NULL, 1, 0, 100, NULL );
1529 recalc_table(); 1545 recalc_table();
1530 reset_slides(); 1546 reset_slides();
@@ -1532,21 +1548,21 @@ int settings_menu(void)
1532 1548
1533 case 2: 1549 case 2:
1534 rb->set_int("Center margin", "", 1, 1550 rb->set_int("Center margin", "", 1,
1535 &(config.extra_spacing_for_center_slide), 1551 &center_margin,
1536 NULL, 1, 0, 80, NULL ); 1552 NULL, 1, 0, 80, NULL );
1537 recalc_table(); 1553 recalc_table();
1538 reset_slides(); 1554 reset_slides();
1539 break; 1555 break;
1540 1556
1541 case 3: 1557 case 3:
1542 rb->set_int("Number of slides", "", 1, &(config.show_slides), 1558 rb->set_int("Number of slides", "", 1, &num_slides,
1543 NULL, 1, 1, MAX_SLIDES_COUNT, NULL ); 1559 NULL, 1, 1, MAX_SLIDES_COUNT, NULL );
1544 recalc_table(); 1560 recalc_table();
1545 reset_slides(); 1561 reset_slides();
1546 break; 1562 break;
1547 1563
1548 case 4: 1564 case 4:
1549 rb->set_int("Zoom", "", 1, &(config.zoom), 1565 rb->set_int("Zoom", "", 1, &zoom,
1550 NULL, 1, 10, 300, NULL ); 1566 NULL, 1, 10, 300, NULL );
1551 recalc_table(); 1567 recalc_table();
1552 reset_slides(); 1568 reset_slides();
@@ -1558,13 +1574,13 @@ int settings_menu(void)
1558 reset_slides(); 1574 reset_slides();
1559 break; 1575 break;
1560 case 6: 1576 case 6:
1561 old_val = config.resize; 1577 old_val = resize;
1562 rb->set_bool("Resize Covers", &(config.resize)); 1578 rb->set_bool("Resize Covers", &resize);
1563 if (old_val == config.resize) /* changed? */ 1579 if (old_val == resize) /* changed? */
1564 break; 1580 break;
1565 /* fallthrough if changed, since cache needs to be rebuilt */ 1581 /* fallthrough if changed, since cache needs to be rebuilt */
1566 case 7: 1582 case 7:
1567 rb->remove(CACHE_PREFIX "/ready"); 1583 cache_version = 0;
1568 rb->remove(EMPTY_SLIDE); 1584 rb->remove(EMPTY_SLIDE);
1569 rb->splash(HZ, "Cache will be rebuilt on next restart"); 1585 rb->splash(HZ, "Cache will be rebuilt on next restart");
1570 break; 1586 break;
@@ -1573,6 +1589,7 @@ int settings_menu(void)
1573 return PLUGIN_USB_CONNECTED; 1589 return PLUGIN_USB_CONNECTED;
1574 } 1590 }
1575 } while ( selection >= 0 ); 1591 } while ( selection >= 0 );
1592 configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION);
1576 return 0; 1593 return 0;
1577} 1594}
1578 1595
@@ -1611,55 +1628,6 @@ int main_menu(void)
1611} 1628}
1612 1629
1613/** 1630/**
1614 Fill the config struct with some defaults
1615 */
1616void set_default_config(void)
1617{
1618 config.spacing_between_slides = (LCD_WIDTH - DISPLAY_WIDTH) / 8;
1619 config.extra_spacing_for_center_slide = (LCD_WIDTH - DISPLAY_WIDTH) / 16;
1620 config.show_slides = 4;
1621 config.avg_album_width = 0;
1622 config.zoom = 100;
1623 config.show_fps = false;
1624 config.resize = true;
1625 config.show_album_name = album_name_top;
1626}
1627
1628/**
1629 Read the config file.
1630 For now, the size has to match.
1631 Later a version number might be appropiate.
1632 */
1633bool read_pfconfig(void)
1634{
1635 set_default_config();
1636 /* defaults */
1637 int fh = rb->open( CONFIG_FILE, O_RDONLY );
1638 if ( fh < 0 ) { /* no config yet */
1639 return true;
1640 }
1641 int ret = rb->read(fh, &config, sizeof(struct config_data));
1642 rb->close(fh);
1643 if ( ret != sizeof(struct config_data) ) {
1644 set_default_config();
1645 rb->splash(2*HZ, "Config invalid. Using defaults");
1646 }
1647 return true;
1648}
1649
1650/**
1651 Write the config file
1652 */
1653bool write_pfconfig(void)
1654{
1655 int fh = rb->creat( CONFIG_FILE );
1656 if( fh < 0 ) return false;
1657 rb->write( fh, &config, sizeof( struct config_data ) );
1658 rb->close( fh );
1659 return true;
1660}
1661
1662/**
1663 Animation step for zooming into the current cover 1631 Animation step for zooming into the current cover
1664 */ 1632 */
1665void update_cover_in_animation(void) 1633void update_cover_in_animation(void)
@@ -1723,20 +1691,20 @@ static inline void draw_gradient(int y, int h)
1723 1691
1724static void track_list_yh(int char_height) 1692static void track_list_yh(int char_height)
1725{ 1693{
1726 switch (config.show_album_name) 1694 switch (show_album_name)
1727 { 1695 {
1728 case album_name_hide: 1696 case album_name_hide:
1729 track_list_y = (config.show_fps ? char_height : 0); 1697 track_list_y = (show_fps ? char_height : 0);
1730 track_list_h = LCD_HEIGHT - track_list_y; 1698 track_list_h = LCD_HEIGHT - track_list_y;
1731 break; 1699 break;
1732 case album_name_bottom: 1700 case album_name_bottom:
1733 track_list_y = (config.show_fps ? char_height : 0); 1701 track_list_y = (show_fps ? char_height : 0);
1734 track_list_h = LCD_HEIGHT - track_list_y - char_height * 2; 1702 track_list_h = LCD_HEIGHT - track_list_y - char_height * 2;
1735 break; 1703 break;
1736 default: /* case album_name_top */ 1704 default: /* case album_name_top */
1737 track_list_y = char_height * 2; 1705 track_list_y = char_height * 2;
1738 track_list_h = LCD_HEIGHT - track_list_y - 1706 track_list_h = LCD_HEIGHT - track_list_y -
1739 (config.show_fps ? char_height : 0); 1707 (show_fps ? char_height : 0);
1740 break; 1708 break;
1741 } 1709 }
1742} 1710}
@@ -1831,7 +1799,7 @@ void select_prev_track(void)
1831 */ 1799 */
1832void draw_album_text(void) 1800void draw_album_text(void)
1833{ 1801{
1834 if (0 == config.show_album_name) 1802 if (0 == show_album_name)
1835 return; 1803 return;
1836 1804
1837 int albumtxt_w, albumtxt_h; 1805 int albumtxt_w, albumtxt_h;
@@ -1865,7 +1833,7 @@ void draw_album_text(void)
1865 prev_center_index = center_index; 1833 prev_center_index = center_index;
1866 } 1834 }
1867 1835
1868 if (config.show_album_name == album_name_top) 1836 if (show_album_name == album_name_top)
1869 albumtxt_y = albumtxt_h / 2; 1837 albumtxt_y = albumtxt_h / 2;
1870 else 1838 else
1871 albumtxt_y = LCD_HEIGHT - albumtxt_h - albumtxt_h/2; 1839 albumtxt_y = LCD_HEIGHT - albumtxt_h - albumtxt_h/2;
@@ -1904,10 +1872,7 @@ int main(void)
1904 } 1872 }
1905 } 1873 }
1906 1874
1907 if (!read_pfconfig()) { 1875 configfile_load(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION);
1908 rb->splash(HZ, "Error in config. Please delete " CONFIG_FILE);
1909 return PLUGIN_ERROR;
1910 }
1911 1876
1912 init_reflect_table(); 1877 init_reflect_table();
1913 1878
@@ -1919,8 +1884,9 @@ int main(void)
1919 rb->splash(HZ, "No albums found. Please enable database"); 1884 rb->splash(HZ, "No albums found. Please enable database");
1920 return PLUGIN_ERROR; 1885 return PLUGIN_ERROR;
1921 } 1886 }
1922 1887
1923 if (!create_albumart_cache(config.avg_album_width == 0)) { 1888 number_of_slides = album_count;
1889 if ((cache_version != CACHE_VERSION) && !create_albumart_cache()) {
1924 rb->splash(HZ, "Could not create album art cache"); 1890 rb->splash(HZ, "Could not create album art cache");
1925 return PLUGIN_ERROR; 1891 return PLUGIN_ERROR;
1926 } 1892 }
@@ -2022,7 +1988,7 @@ int main(void)
2022 frames = 0; 1988 frames = 0;
2023 } 1989 }
2024 /* Draw FPS */ 1990 /* Draw FPS */
2025 if (config.show_fps) 1991 if (show_fps)
2026 { 1992 {
2027#ifdef USEGSLIB 1993#ifdef USEGSLIB
2028 MYLCD(set_foreground)(G_BRIGHT(255)); 1994 MYLCD(set_foreground)(G_BRIGHT(255));
@@ -2030,7 +1996,7 @@ int main(void)
2030 MYLCD(set_foreground)(G_PIX(255,0,0)); 1996 MYLCD(set_foreground)(G_PIX(255,0,0));
2031#endif 1997#endif
2032 rb->snprintf(fpstxt, sizeof(fpstxt), "FPS: %d", fps); 1998 rb->snprintf(fpstxt, sizeof(fpstxt), "FPS: %d", fps);
2033 if (config.show_album_name == album_name_top) 1999 if (show_album_name == album_name_top)
2034 fpstxt_y = LCD_HEIGHT - 2000 fpstxt_y = LCD_HEIGHT -
2035 rb->screens[SCREEN_MAIN]->getcharheight(); 2001 rb->screens[SCREEN_MAIN]->getcharheight();
2036 else 2002 else
@@ -2145,7 +2111,9 @@ enum plugin_status plugin_start(const void *parameter)
2145 rb->cpu_boost(false); 2111 rb->cpu_boost(false);
2146#endif 2112#endif
2147 if ( ret == PLUGIN_OK ) { 2113 if ( ret == PLUGIN_OK ) {
2148 if (!write_pfconfig()) { 2114 if (configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS,
2115 CONFIG_VERSION))
2116 {
2149 rb->splash(HZ, "Error writing config."); 2117 rb->splash(HZ, "Error writing config.");
2150 ret = PLUGIN_ERROR; 2118 ret = PLUGIN_ERROR;
2151 } 2119 }